Amr Mahmoud
Amr Mahmoud

Reputation: 29

Flutter deep link open in web browser

I'm implementing deep linking in my Flutter app using auto route. However, when I try to test the deep link, it opens in the browser on both platforms instead of directly in the app. Here's what I've done so far:

1. AndroidManifest Configuration

<meta-data 
              android:name = "flutter_deeplinking_enabled"
              android:value ="true" 
            />
            <intent-filter android:autoVerify="true" android:exported="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" android:host="www.my-host"  android:pathPrefix="/offer/" />
           </intent-filter>

2. Main Application Class

This is the main class for my app:

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Listener(

      child: OverlaySupport.global(
        child: RestartWidget(
          child: MaterialApp.router(
            routerConfig: appRouter.config(deepLinkBuilder: (deepLink) {
              log(deepLink.path.toString());
              if (deepLink.path.startsWith('/offer')) {
               
                return DeepLink(
                  [OfferDetailsRoute()]
                );
              } else {
                return DeepLink.defaultPath;
              }
            }),
            builder: (context, widget) => ResponsiveWrapper.builder(
              ClampingScrollWrapper.builder(context, widget!),
              breakpoints: const [],
            ),
            debugShowCheckedModeBanner: false,
          ),
        ),
      ),
    );

}
}

3. Assetlinks Configuration

I also set up the configuration on my website and created assetlinks.json with the following content:

[   {     "relation": ["delegate_permission/common.handle_all_urls"],     "target": {       "namespace": "android_app",       "package_name": "my_package_name",       "sha256_cert_fingerprints": ["my_sha256_cert_fingerprints"]     }   } ]

Issue

When I run the domain link, it opens in the browser. On Android, if I delete all the browsers from the device, it then opens the app directly.

Note : I have double checked the domain and the sha256 and all is alright

Upvotes: 1

Views: 148

Answers (0)

Related Questions