How to open the app on android from deeplink in browser?


Hi, I want to open the app from browser by using Android Intent with Chrome as the spec at here:

Below is my code to handle linking:

if (navigator.userAgent.match(/Chrome/)) {
//linkingUrl = "MYAPP://+redirect?post_id=123xyz"
var intent = linkingUrl + '/#Intent;scheme=$schema$;package=abcxyz;S.browser_fallback_url=' + encodeURIComponent(androidAppStore) + ';end';
 intent = intent.replace('MYAPP', 'intent');
intent = intent.replace('$schema$', 'MYAPP'); 
document.location = intent;

But this Intent doesn’t work so it did fallback to the app link on Google Play.
Please help me to show any problem for this code, thanks!


hey, I checked out the docs and looks like your syntax is right (assuming no typos in package name or other values)

my hunch is that the error has to do something with these lines:

"Some example cases where Chrome does not launch an external application are as follows:

The intent could not be resolved, i.e., no app can handle the intent.
JavaScript timer tried to open an application without user gesture."

I think setting document.location when you detect a chrome browser may be causing this to fail, as there is no user action involved. I would try debugging the link by just having an link element and see if the intent works when you click on it (since the browser will detect this as the user initiating an action)


It’s interesting to see the comment about document.location instead of a user deliberately clicking a link.

I am finding that setting the location to a Linking URI doesn’t work in a the Genymotion emulator, but does work on an Android phone, and also works on iOS. This happens on the example Expo project where after 5 seconds it sets window.location.href to redirect back to the app: it works on iOS and a real Android device but not in Genymotion emulator. It just sits there without redirecting back to the app, window.location.href does not activate the link.