Jacob Jefferson
Jacob Jefferson

Reputation: 431

Android deep links not working due to supported web addresses being disabled by default

My app used to work fine with deep links, I haven't changed anything in the app but what has seemed to change is that when freshly installing the app, in the app settings - Set as default - Supported web addresses my website url that the deep links are supposed to work off of is disabled as default, I have to enable it manually to make it work.

How can I make it install with this being enabled automatically

Upvotes: 43

Views: 29996

Answers (5)

Daniel López
Daniel López

Reputation: 141

My solution was clicking on the Android Studio Tools -> App Links Assistant and create the manifest from there.

It created a separated intent filter for each host and domain I had, instead of having one for all.

Then I added the android:autoVerify="true" label and it worked like a charm.

Upvotes: 3

Loz
Loz

Reputation: 141

In our case using cordova and ionic-plugin-deeplinks, everything was seemingly set up correctly but this setting was still off by default when installing the app.

The issue turned out to be a problem with how ionic-plugin-deeplinks had added support for multiple deeplink schemes, which caused a bunch of blank <data> attributes to be added to AndroidManifest.xml when the app was built. We fixed it by forking the plugin repo and removing all but the first of the <data> attributes they had added to their plugin.xml nested in the <config-file> element, starting with scheme 2 downward (an example element is below):

<data android:scheme="$DEEPLINK_2_SCHEME" android:host="$DEEPLINK_2_HOST" android:pathPrefix="$ANDROID_2_PATH_PREFIX" />

This removed the blank <data> entries in AndroidManifest.xml on build and the issue was solved.

Upvotes: 1

Alan Nelson
Alan Nelson

Reputation: 1229

As a work-around for those implementing Adobe Assurance or some other third-party service, you can use the following filter. If the schema isn't http/https, it should work.

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:scheme="sampleapp"
                    android:host="my.appname.app" />
        </intent-filter>

Upvotes: 0

amitgur
amitgur

Reputation: 462

After spending a whole day on that questions, here is my solution: For me, my apk had a different package name from that in the my-domain.com/.well-known/assetlinks.json

I found it out only after examining it with this service

My suggestion if you ran into that problem

  1. check that your .well-known has no errors using the URL (replace https://my-domain.com with your domain)

https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://my-domain.com&relation=delegate_permission/common.handle_all_urls

  1. After installing the apk, check that the deep link verification is ok by using these commands if they are not verified, they will appear with that toggle switch turn off.

3.If you still have that problem you can examine the adb logcat of your device and see the error why this verification failed.

Upvotes: 10

Mayur Dhurpate
Mayur Dhurpate

Reputation: 1282

This is happening due to a recent change introduced in Android 12. As per the documentation:

Starting in Android 12 (API level 31), a generic web intent resolves to an activity in your app only if your app is approved for the specific domain contained in that web intent. If your app isn't approved for the domain, the web intent resolves to the user's default browser app instead.

Before Android 12, opening generic web URLs which were added as a deep link in AndroidManifest showed a dialog to choose between the app and the browser. Starting Android 12, developers are expected to:

  1. Add android:autoVerify="true" to the web URL intents for which Android will verify if the domain is associated with the same app. These associated deeplinks are also called Android App Link.s (doc link)
  2. Declare the association between your website and your intent filters by hosting a Digital Asset Links JSON file at the following location: https://domain.name/.well-known/assetlinks.json (doc link)

After this, when the app is installed and Deep link (Android App Link) is triggered, Android will verify the association and directly open the deeplink in the app (it'll not show the app chooser dialog as well in the intent.)

Upvotes: 19

Related Questions