How to obtain url path after using an Android app link on Flutter?

67 views Asked by At

My application uses Android app links to redirect the user from another app. It needs to distinguish between being launched by the user or redirected by another application. The URL of redirects have a distinct path in order to distinguish the launch origin, however, Flutter always launches the default path.

The URL navigated is https://myusername.github.io/result

Intent filter:

<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" />
    <data android:scheme="https" />
    <data android:host="myusername.github.io"/>
    <data android:pathPrefix="/result"/>
</intent-filter>

App code

void main() {
  runApp(
    MaterialApp(
      title: 'Example',
      theme: ThemeData(primarySwatch: Colors.blue),
      routes: {
        // This route is shown regardless of the launch origin
        '/': (context) => const Center(child: Text("/")),

        // This route is never reached
        '/result': (context) => const Center(child: Text("/result")),
      },
    ),
  );
}

How to launch the app with the correct route?

0

There are 0 answers