0

I would like to open an app (if its installed) when I click on the link on my webpage. I've implemented App Links according to official docs but the link is opened in Chrome and my app is not offered to handle the link. If I click on the link in Messages app for example, it works correctly. I think that it's some limitation of the Chrome but I cant find anything online about that. If I try to turn off the verification for App links and implement it just like regular deeplinks it does not work either. Do I need to implement Chrome Intent s?

This is my intent filter

 <activity
  android:name=".MainActivity"
  android:windowSoftInputMode="adjustNothing">

  <intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data
      android:host="mydomain.com"
      android:pathPattern="/.*/app-microsite"
      android:scheme="http" />
    <data
      android:host="www.mydomain.com"
      android:pathPattern="/.*/app-microsite"
      android:scheme="http" />
    <data android:scheme="https" />
    </intent-filter>
</activity>
Billda
  • 5,707
  • 2
  • 25
  • 44
  • Are there any messages in the logcat during apk installation? Search for `IntentFilterIntentSvc` and `SingleHostAsyncVerifier`. – Simon Marquis Oct 16 '19 at 11:42
  • Yep, I've got two `false` results and two `true` results for `SingleHostAsyncVerifier`. I dont think that there will be a problem with verification, or it would results in such behavior? – Billda Oct 16 '19 at 14:48
  • If verification fails, the AppLinking is disabled. Only basic deeplinking remains enabled. – Simon Marquis Oct 16 '19 at 15:08
  • Also, it is expected that if you copy/paste the url in the search bar on chrome, it won't trigger the deeplink (it must be a link). – Simon Marquis Oct 16 '19 at 15:10
  • I've detected the failed verifications and I've removed them from manifest (for testing purposes). Right now I get only one result that passes verification. The deeplink is still not working though. It loads the page in chrome. Isnt there i a problem if I dont use custom scheme and i am using http/https? Maybe chrome handle this links by default and does not let me handle them in my app? – Billda Oct 16 '19 at 15:36
  • What is the exact procedure you're following to test this deeplink with chrome? – Simon Marquis Oct 17 '19 at 08:16
  • well, I click on a link on the webpage. And I expect it to open the app. But it opens the link in chrome instead. – Billda Oct 17 '19 at 08:21
  • And if you open the settings page of you app, then "Open by default", does the "Supported links" appear? and "Open supported links" is correctly set? – Simon Marquis Oct 17 '19 at 08:24
  • Yes, its there and its correct. – Billda Oct 17 '19 at 08:26
  • Well I can't find out what's wrong here. You should start with a working example https://developer.android.com/training/app-links/deep-linking.html and modify it until it corresponds to your needs. Then you might found your issue during this process. – Simon Marquis Oct 17 '19 at 08:49
  • And it works for you? You click on a link on a webpage and it opens the app? Because i dont know what I should be doing differently, the implementation is clearly correct if it works from Mesasages/Slack app and not from the Chrome. – Billda Oct 17 '19 at 08:56
  • Yes it does work fine. You can use this guide (made by myself) https://simonmarquis.github.io/Android-App-Linking It contains a sample app you can use to test deeplinking. – Simon Marquis Oct 17 '19 at 09:00
  • Thanks, thats a really good repo. I've figure out that its working correctly if I click on the link somewhere else (I've tested it in README in my github repo). It looks like that there is a problem only on our webpage. I will try to figure it out with our frontend guys, thanks again :) – Billda Oct 17 '19 at 10:26
  • 1
    Oh, I think I know what this is... Is your webpage where you click the link on the same domain name? If that is the case, chrome will ignore the deeplink and keep the user on the webpage. – Simon Marquis Oct 17 '19 at 11:13

1 Answers1

0

I'm putting the comment by Simon Marquis, that helped me, here as an answer to that question, so following visitors might see it more easily.

Deep links are not working if you're using relative links on the same domain.

E.g. you have this page: example.com/index.html

<a href="appstuff/foo">This will open in browser</a>
<a href="https://example.com/appstuff/foo">This will open the app</a>
Ridcully
  • 23,362
  • 7
  • 71
  • 86