Git Product home page Git Product logo

Comments (7)

douglasjunior avatar douglasjunior commented on September 6, 2024

Unfortunately, this is how Google renders the reCAPTCHA dialog on mobile browsers.

You can try to inject JS to create CSS code inside the webview and force the wanted position, but I can't guarantee that it will work forever.

Example:

<Recaptcha
   webViewProps={{
       injectedJavaScript: `
           // your javascript code here
       `
   }}
/>

Reference: https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#injectedjavascript

from react-native-recaptcha-that-works.

w1ll-dev avatar w1ll-dev commented on September 6, 2024

iam-ben You can also use style prop to put the challenge inside a safe area using a margin. Example:

const Recaptcha = forwardRef(
  ({ onSuccess, onExpire }: RecaptchaProps, ref: Ref<RecaptchaRef>) => {
    const insets = useSafeAreaInsets();

    const styles = useMemo(
      () => ({
        marginTop: insets.top,
      }),
      [insets.top]
    );

    return (
      <RNRecaptcha
        ref={ref}
        lang={"en"}
        siteKey={config.RECAPTCHA_SITE_KEY}
        baseUrl={config.GRAPHQL_URI}
        size={"normal"}
        theme={"dark"}
        enterprise={true}
        action={RecaptchaAction.MobileLogin}
        onExpire={onExpire}
        onVerify={onSuccess}
        style={styles}
      />
    );
  }
);

resized

from react-native-recaptcha-that-works.

douglasjunior avatar douglasjunior commented on September 6, 2024

Good option @w1ll-dev.

from react-native-recaptcha-that-works.

kashee-lv avatar kashee-lv commented on September 6, 2024

Facing same issue but @w1ll-dev top part is not looking blur as in bottom

from react-native-recaptcha-that-works.

kashee-lv avatar kashee-lv commented on September 6, 2024

@w1ll-dev please check the screenshot it not covering to the whole screen

const insets = useSafeAreaInsets();

const styles = useMemo(
() => ({
marginTop: insets.top,
}),
[insets.top],
);

<SafeAreaView style={{flex: 1, backgroundColor: colors.background}}> <View style={{flex: 1}}> <Recaptcha ref={recaptcha} siteKey="" baseUrl="https://www.google.com/" onVerify={onVerify} onExpire={onExpire} style={styles} /> </View> </SafeAreaView>

image1
image2

from react-native-recaptcha-that-works.

w1ll-dev avatar w1ll-dev commented on September 6, 2024

kashee-lv, my approach just fix the status bar cover problem.

from react-native-recaptcha-that-works.

dryusha avatar dryusha commented on September 6, 2024

I encountered a similar issue and was able to resolve it with the following approach:

const insets = useSafeAreaInsets();

webViewProps={{
  injectedJavaScript: `
    const interval = setInterval(() => {
      const iFrames = document.querySelectorAll('iframe');
      let lastDivWithIFrame = null;

      iFrames.forEach((iframe) => {
        const parentDiv = iframe.parentElement;

        if (parentDiv.tagName.toLowerCase() === 'div') {
          const zIndex = window.getComputedStyle(parentDiv).zIndex;
          const width = parentDiv.style.width;

          if (zIndex === "2000000000" && width.includes('px')) {
            lastDivWithIFrame = parentDiv;
          }
        }
      });

      if (lastDivWithIFrame) {
        lastDivWithIFrame.style.marginTop = "${insets.top}px";
        clearInterval(interval);
      }
    }, 500);
  `,
}}

This script continuously checks for <iframe> elements within

containers that match specific conditions (i.e., zIndex of "2000000000" and a width defined in pixels). Once the target element is identified, it adjusts the marginTop property of the parent
to match the top inset value provided by useSafeAreaInsets, and then clears the interval to stop further execution.

This approach resolved the issue in my case. I hope it helps others facing similar challenges.

from react-native-recaptcha-that-works.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.