Search code examples
androidgoogle-chromedeep-linkingfallback

Android Deeplink and Fallback to URL


I need to implement deeplink and URL fallback in case app is not present.

I can open my app using intent filter and URL scheme but not able to fall back to my URL when app is not present.

Here is my code

setTimeout(function() {
  window.location =
    "http://m.abcd.com";
}, 25);

window.location = "abcd://";

abcd is the URL scheme provided in intentfilter.

What could be the issue?


Solution

  • For Google Chrome I have found it best to create a intent like below and pass that to window.location

    window.location = 'intent://@Intent;scheme=abcd://;package=com.abcd.yourapp;S.browser_fallback_url=http://m.abcd.com'
    

    What this will do is attempt your protocol, if it doesn't exist on the device it will try the fallback. Mind you the fallback I have not experienced to work on the native browser. But if there is no fallback and a package name exists it will attempt to take the user to the Google Play App and look up the app by the provided package name. If the app isn't on Google Play it will say "No Results Found"