Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle callback urls in the app from InAppBrowser. #439

Open
mksmanish opened this issue Sep 26, 2023 · 1 comment
Open

How to handle callback urls in the app from InAppBrowser. #439

mksmanish opened this issue Sep 26, 2023 · 1 comment

Comments

@mksmanish
Copy link

mksmanish commented Sep 26, 2023

```
      const openLink = async (url) => {
try {
  if (await InAppBrowser.isAvailable()) {
    InAppBrowser.open(url, {
      // Configure your InAppBrowser options here
      // ...
     
    })
      .then((result) => {
        console.log("printing result", result);
        if (result.type === "loadstop") {
          // The "loadstop" event occurs when the page/resource finishes loading.
          const callbackUrl = result.url;
          console.log(`Received callback URL: ${callbackUrl}`);

          // Check if this is the callback URL you're expecting
          if (callbackUrl.startsWith("your-callback-url")) {
            // Handle the callback URL here
            // You can parse the URL and extract data as needed
          }
        }
      })
      .catch((error) => {
        console.error("InAppBrowser open error:", error);
      });
  } else {
    // Fallback to Linking if InAppBrowser is not available
    Linking.openURL(url);
  }
} catch (error) {
  console.error("An error occurred:", error);
}

};

@Noitham
Copy link

Noitham commented Oct 3, 2023

It seems callbacks are not supported with the default InAppBrowser.open, only with openAuth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants