I’m trying to open a URL in Google Chrome (instead of LinkedIn’s in-app WebView) using an Android Intent. My current code works on some devices but causes infinite loading in LinkedIn’s WebView or redirects to the Play Store.
Current Code (Problem):
const url = window.location.href;
if (/android/i.test(navigator.userAgent)) {
window.location.href = googlechrome://${window.location.href.replace(/^https?:\/\//, '')};
return;
}
How can I force the URL to open in Chrome (not WebView) only when possible?
LinkedIn’s web view may be blocking the redirect leading it to load infinitely, but I am unsure.
It seems that opening the URL in a Google Chrome web browser works. As a workaround, you might consider offering your users a way to copy the URL and ask them to open it in a web browser instead of LinkedIn’s in-app web view.
Additionally, using a standard web browser over the in-app web view is the recommended way for authentication flows.
Check out this post, which explains the best current practice for OAuth 2.0 for native apps.