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

Close inappbrowser on deeplink #312

Open
BenjaminSAILcloud opened this issue Dec 2, 2021 · 12 comments
Open

Close inappbrowser on deeplink #312

BenjaminSAILcloud opened this issue Dec 2, 2021 · 12 comments
Labels
discussion 🔥 Discussions about this plugin help wanted Extra attention is needed question Further information is requested

Comments

@BenjaminSAILcloud
Copy link

Which platform(s) does your issue occur on?

  • Both
  • All versions
  • emulator

Please, provide the following version numbers that your issue occurs with:

  • CLI:
react-native-cli: 2.0.1
react-native: 0.64.0
  • Plugin(s):
"react-native-inappbrowser-reborn": "3.6.3"

Hi,

I am using the inappbrowser to access a social website and I am NOT using it for authentication. In this website, there are buttons that links back to the app using deeplinks. I know they are working because when I access the website in browsers (e.g. Safari or Chrome) on the device, the deeplinks opens the app on the correct page. However when using the inappbrowser nothing happens.

How can I make the inappbrowser to handle correctly deeplinks without using the openAuth() method ?

Thanks

@BenjaminSAILcloud
Copy link
Author

Hi,

Uppon more investigation, I found out that the deeplinks work correctly (e.g. they open the correct screen using react navigation) however when clicking the deeplink, the inappbrowser modal does not close...

@andriiDatsiuk
Copy link

@BenjaminSAILcloud take a look at a console of the page that should redirect user back to the app, probably you will see something like this: "Navigation is blocked: ...". I'm facing this issue as well. Here's what I've found so far.

https://bugs.chromium.org/p/chromium/issues/detail?id=738724
https://www.py4u.net/discuss/629990

The issue breaks auth flows with some 3rd party in my case. Users are not redirected back to the app after authentication.

@jdnichollsc
Copy link
Member

Hello folks, please share a reproducible demo project to be able to debug your issue 👍

@jdnichollsc jdnichollsc added help wanted Extra attention is needed question Further information is requested labels Dec 10, 2021
@sgtpsibin

This comment has been minimized.

@mongkuen
Copy link

Hello folks, please share a reproducible demo project to be able to debug your issue 👍

Appreciate the attention

Issue reproduced here: https://github.com/mongkuen/RNInAppBrowser-deeplink-demo

Video of issue
https://www.loom.com/share/26355f2b3c874c50960055275637041a

@TheWirv
Copy link
Contributor

TheWirv commented Apr 19, 2022

I second this. We have payment integration via InAppBrowser and have been using openAuth up until now, but that always triggers the OS dialog, "{App name} Wants to Use {payment provider URL} to Sign In", which is really annoying, and confusing to end users. I have tried just replacing the openAuth with open, but after that the redirect after successful payment just simply doesn't work anymore. E.g. PayPal is just "processing" forever, whereas before it redirected back to the app afterwards.
I have tried this comment, but that also does not work for me at all somehow. I tried putting a console.log inside the event listener, but nothing appears.

@jdnichollsc Is there a reason why the redirection logic has only been implemented for openAuth?

Oh, and on Android everything works fine. The Custom Tabs knows how to redirect out of the box.

@mongkuen
Copy link

mongkuen commented Apr 20, 2022

This is probably a SFSafariViewController concern only.

Not an iOS/Objective C dev, and this solution is in swift, but I imagine this approach here might be close to the desired behavior?

Then maybe a documentation section on how to modify AppDelegate.m/AppDelegate.h to support view dismissal?

Thank you whoever is taking a look at this, it's very much appreciated :)

@TheWirv
Copy link
Contributor

TheWirv commented Apr 21, 2022

Yeah, something's up here. The SFSafariViewController just won't redirect. I have tested whether our API's redirection mechanism maybe wasn't working correctly by opening the payment process in Safari via the bottom right button that SFSafariViewController provides. After payment was successful, Safari without any problem redirects to the app, or at least it asks whether to "open the URL in the app". But inside of SFSafariViewController there's just nothing happening.

@jdnichollsc
Copy link
Member

I second this. We have payment integration via InAppBrowser and have been using openAuth up until now, but that always triggers the OS dialog, "{App name} Wants to Use {payment provider URL} to Sign In", which is really annoying, and confusing to end users. I have tried just replacing the openAuth with open, but after that the redirect after successful payment just simply doesn't work anymore. E.g. PayPal is just "processing" forever, whereas before it redirected back to the app afterwards. I have tried this comment, but that also does not work for me at all somehow. I tried putting a console.log inside the event listener, but nothing appears.

@jdnichollsc Is there a reason why the redirection logic has only been implemented for openAuth?

Oh, and on Android everything works fine. The Custom Tabs knows how to redirect out of the box.

We're using the same strategy of WebBrowser (Expo), please check here for more details

@alexisloiselle
Copy link

Hey @TheWirv, I wanted to let you know that I got the comment you referenced to work by adding this to the AppDelegate.swift:

  func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    return RCTLinkingManager.application(app, open: url, options: options)
  }

Hope it helps!

@focux
Copy link

focux commented May 19, 2023

FYI, if you just want to close the in-app browser after handling a deep link, you just need to do:

InAppBrowser.close()

In your Linking.addEventListener callback.

@JJbings
Copy link

JJbings commented Aug 16, 2023

FYI, if you just want to close the in-app browser after handling a deep link, you just need to do:

InAppBrowser.close()

In your Linking.addEventListener callback.

This does not seem to work for me as the callback is executed after the browser is closed.

(OnAndroid) When pressing the menu --> "Open in Chrome" then the redirect is handled properly and redirects to the APP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion 🔥 Discussions about this plugin help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

9 participants