avioli / uni_links

Flutter plugin for accepting incoming links.
BSD 2-Clause "Simplified" License
563 stars 311 forks source link

Deep link immediately opens a default browser on Xiaomi with MIUI not asking #166

Open Nazarii77 opened 1 year ago

Nazarii77 commented 1 year ago

It works as in the example:

Deep link immediately opens a default browser on Xiaomi with MIUI

<!-- Deep Links -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST -->
            <data
                android:scheme="https"
                android:host="my.reservation"  />
        </intent-filter>

When I execute powershell script:

.\adb shell 'am start -W -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://my.reservation/path/portion/?uid=123&token=abc"' it works fine!

But in real world scenario when I send myself EMAIL with the link https://my.reservation/path/portion/?uid=123&token=abc and click on mobile phone it opens the default browser, when I type this in browser also it tries to google it. I have a MIUI from XIAOMI operation system on my android device

Nazarii77 commented 1 year ago

so I have decided to try this: instead of rewriting https rule I will make my own links like "myapp://reservation/123" and in scheme will use "myapp" and for this to be link I will style it so it will look like link in email

Nazarii77 commented 1 year ago

with custom scheme mobile email blocks the deep link :( and the link is not clickable

akarabas-esarj commented 1 year ago

App Links only work with https scheme and require a specified host, plus a hosted file - assetlinks.json. Check the Guide links below.

If you have done these steps, you should generate a signed apk in release mode and try it with it. If the fingerprint in assetlinks.json and the keystore where the application is signed are the same, app-links should work.

roiskhoiron commented 1 year ago

App Links only work with https scheme and require a specified host, plus a hosted file - assetlinks.json. Check the Guide links below.

If you have done these steps, you should generate a signed apk in release mode and try it with it. If the fingerprint in assetlinks.json and the keystore where the application is signed are the same, app-links should work.

so there is i cant take the result work normaly while on debug mode?

roiskhoiron commented 1 year ago

in my case, i use xiaomi MIUI its work normal debug or release mode. but in other phone ex. 'Oppo' its not work. why ?

roiskhoiron commented 1 year ago

i think its about intent security polcy between vendor.

Nazarii77 commented 1 year ago

I had the same exact issue, my xiomi is working on Android 10 which allows you to test such case and Oppo is working on newer version of Android like 12 which by default blocks such scenario

Nazarii77 commented 1 year ago

I have soled the issue, so the android:autoVerify="true" allows for android 10 (Xiomi) to test it without actually setting up assetlinks.json but will show you choosing option between browser and app. If you do everything correct it will automatically open app (testing on android 12 is impossible without setting assetlinks and signing app which is terrible)

<data android:host="${APP_LINK_HOST}" /> <data android:pathPattern="/reservation/.*" /> <data android:scheme="https" />