droibit / react-native-custom-tabs

Chrome Custom Tabs for React Native.
https://www.npmjs.com/package/react-native-custom-tabs
Apache License 2.0
187 stars 108 forks source link

Dismiss custom tabs #15

Open edo1493 opened 7 years ago

edo1493 commented 7 years ago

I am not sure, but I guess there is no way to dismiss custom tabs, right? I just want dismiss it programmatically from RN.

ataillefer commented 7 years ago

Don't think so, but why would you want to do this?

edo1493 commented 7 years ago

I am using it for a OAuth login flow, so I would like to close the view, once the user has logged in.

I can still do it cause I have an intent that listens to a deep link, so the custom tabs view is shutdown, when the login is successful.

ataillefer commented 7 years ago

Yes that's the way, by handling the OAuth redirect URL with a listener that finally navigates to the another view once the flow is done, typically your app's home view:

componentDidMount() {
  Linking.addEventListener('url', this._handleOAuthRedirectURL);
}
...
_handleOAuthRedirectURL(options) {
   // do domething with options.url
   ...
   // navigate to the home view
}
petlys commented 6 years ago

I'm working on a project which is just an app in a Webview utilising this package for OAuth authentication. How would one go about dismissing the custom tabs in this case?

rsjolundchas commented 5 years ago

Yes that's the way, by handling the OAuth redirect URL with a listener that finally navigates to the another view once the flow is done, typically your app's home view:

componentDidMount() {
  Linking.addEventListener('url', this._handleOAuthRedirectURL);
}
...
_handleOAuthRedirectURL(options) {
   // do domething with options.url
   ...
   // navigate to the home view
}

Do you know how to handle this when the the app with chrome-tabs is in the background? In that case the Linking event never seems to be fired.