proyecto26 / react-native-inappbrowser

📱InAppBrowser for React Native (Android & iOS) 🤘
https://www.npmjs.com/package/react-native-inappbrowser-reborn
MIT License
1.31k stars 223 forks source link

Passing local storage data back to app? #329

Closed hrayne closed 2 years ago

hrayne commented 2 years ago

Nice repo, thanks for maintaining it and being responsive on the issues.

Is there any way to pass data from the browser's local storage back into the app? I know deep linking and using route params is the suggested method for passing data back to the app, but I'm struggling to do this in a localstorage/non-auth context.

Essentially, I'm looking to have the user open a webpage via react-native-inappbrowser, do some action on that web page, and then hit 'Done' to fire a callback that communicates some data from local storage back to the app. I've read up on all the issues (e.g. #92, #319, #325) but none mention accessing local storage and I'm not sure if this is beyond the limitations of this module.

Additional context: I was originally using react-native-webview and postMessage to transmit data from the webview back to the app. This worked great in development, however Apple's App Tracking Transparency policy means webview is not feasible for release - I have no control over the tracking on the 3rd party website that was being served in the webview, if the user declines the App Tracking Transparency request then I have to prevent the user from viewing the webview, which is deemed as 'gating' content by Apple. Total catch 22. It seems serving the content via browser, rather than webview, is the best workaround.

Any advice/assistance appreciated.

jdnichollsc commented 2 years ago

Hello mate, hope you're doing well

I'm not sure how to do that, in my experience that's not supported by Chrome CustomTabs or SafariViewController for security concerns, the only way to pass data from the System Browser to your App is using a redirection and then using React Native Linking to get that info.

Thanks for understanding, any pull request is welcome!

Best, Juan

hrayne commented 2 years ago

No problem, appreciate the info & quick reply - all the best

smith-chris commented 2 years ago

You could open deep link url from within the inappbrowser and attach whatever information you want as a query parameter