'React Native Samsung Universal Link stopped to work after upgrading to Android 12

Using a Samsung S10e on Android 12, I was able in the past to open our React Native application (https://github.com/pass-culture/pass-culture-app-native) through Universal Links.

We removed first all apps, all other browsers than chrome (such as samsung browswer), and then we did a factory reset using this menu:

enter image description here

It still can't open the app through universal link. All our other test devices from our team are able to open those universal links.

I tested from the email app (Gmail), slack, and so on, nothing work.

This is our assetlinks.json:

https://app.passculture.app/.well-known/assetlinks.json

This is a video demonstrating the bug:

https://user-images.githubusercontent.com/77674046/166442082-9e0189d6-248d-4046-9acd-34d46250c41f.mp4

We recently upgrading the device from Android 11 to Android 12, and it seems Google modified the behavior of applinks:

App links and our configuration seems to be OK.

This is our assetlinks : https://app.testing.passculture.team/.well-known/assetlinks.json

This is the error:

adb shell pm get-app-links app.passculture.testing
  app.passculture.testing:
    ID: 7b7458c4-f595-4840-839c-a6c1089b7b12
    Signatures: [F2:59:8C:3F:07:B3:8E:6D:D0:20:A8:1B:A1:02:7B:82:41:53:88:D8:84:0E:CB:22:87:CC:CD:12:F0:8E:32:7F]
    Domain verification state:
      app.testing.passculture.team: legacy_failure

Consequence are that adb shell am start -a android.intent.action.VIEW \ -c android.intent.category.BROWSABLE \ -d "https://app.testing.passculture.team" only open the web instead of the native application.

Since Android 12 changed the applinks behavior, this is how we are testing but since it stays in legacy_failure, we still open the web :

This is related ressources we have found:

Does anybody can tell what is going on with Android 12 and applinks and how it can be fixed ?



Solution 1:[1]

There was a change in the policy for universal link from Android 12 (sdk 31), Google requires to use Android App Link, if you dont use it the app doesnt open. This article could help you: https://doordash.engineering/2022/01/25/your-deep-links-might-be-broken-web-intents-and-android-12/

Solution 2:[2]

We had to perform two change in order to fix our Android 12

AndroidManifest.xml

<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:scheme="https" />
  <data android:host="www.example.com" />
</intent-filter>

Example: https://github.com/pass-culture/pass-culture-app-native/blob/master/android/app/src/main/AndroidManifest.xml

assetlinks.json

Server side, we needed to verify our site association (assetlinks.json) pass the google validation tool.

  • namespace must be android_app
  • package_name must be the one from the builded app (in our case, we used com.passculture instead of app.passculture.webapp)
  • sha256_signature must be the one from your keystore (in our case, we used the wrong one, using the one provided by google play, it worked)

All those points needed to be exactly like this, otherwise the autoVerify:true would have not work.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 enzou
Solution 2 Dimitri Kopriwa