Universal link opens the flutter app but does not go to the right page
Asked Answered
H

1

8

On iOS, when I click on a url, it opens my Flutter app but stays on the main screen. It does not go to the given page.

For example, if the link is https://my-app.com/page1, the app will just go to /

Here's the AASA:

.well-known/apple-app-site-association

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "com.my-app",
        "paths": ["*"]
      }
    ]
  }
}

ios/Runner/Runner.entitlements

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>aps-environment</key>
    <string>development</string>
    <key>com.apple.developer.associated-domains</key>
    <array>
        <string>applinks:my-app.com</string>
        <string>applinks:my-app-staging.com</string>
    </array>
</dict>
</plist>

Everything passes if I check for the url in https://search.developer.apple.com/appsearch-validation-tool.

My app uses go_router 5.0.1

MaterialApp.router(
  routerConfig: GoRouter(
    routes: [...],
    redirect: (context, state) { ... }
  ),
)

I tried putting a break point in redirect but it never gets executed.
I tried opening the logs of the iOS emulator (Debug > Open System Logs...) but there's no trace when I run this in a terminal:

~ ❯ xcrun simctl openurl booted https://my-app.com/page1
~ ❯ xcrun simctl openurl booted my-app.com://my-app.com/page1

How can I troubleshoot this further?

Edit: the app opens on the right page on Android when I use adb shell am start ... so it must be a config issue on iOS.

Haggai answered 7/11, 2022 at 14:17 Comment(1)
In your AASA "appID": "com.my-app" doesn't have team ID in the appID. But you might already know this and this is just a typo of the curated example.Cardin
I
3

Try to remove the uni_links package if it is installed. The library seems to conflicts with this mechanism.

Iowa answered 9/1, 2023 at 17:53 Comment(2)
any idea what can replace uni_links package in this case?Kath
That was correct; getInitialLink() from uni_links caused a lot of inconsistency. Removing the pub fixes all the shit happens.Briarroot

© 2022 - 2024 — McMap. All rights reserved.