Search code examples
androidflutterdartdeep-linking

Flutter deep links not working from browser


I made changes in Android manifes as suggested here: https://docs.flutter.dev/development/ui/navigation/deep-linking

So, new metadata and config has been added to MainActivity:

<!-- Deep linking -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<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="http" android:host="flutterbooksample.com" />
    <data android:scheme="https" />
</intent-filter>

As a result, when I use adb for testing as they said to do:

adb shell am start -a android.intent.action.VIEW \
    -c android.intent.category.BROWSABLE \
    -d "http://flutterbooksample.com/book/1"

I am getting what I want:

enter image description here

But if I try to open url http://flutterbooksample.com/book/1 directly in browser on my emulator, nothing happens, browser opens page and theres no prompt to open url in my app.

Do I need to do anything else to make it working?


Solution

  • Short Answer

    You can't call the deep link URL from the web browser's search bar. First, you need to create an HTML page. Then you can click the link. It will work.

    More details

    In my case, I created an HTML file with a deep link and send it to my email.

    HTML file

    <a href="myapp://test">Open my app</a>
    

    AndroidManifest.xml

    <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:host="test"
            android:scheme="myapp" />
    </intent-filter>