deeplink_listener

Pub Package

Features

Handling Custom Deep Links and Universal Links Deep linking allows your app to respond to links, whether they come from emails, websites, or other apps. There are two main types:

  • Custom URL Schemes – Works on both iOS and Android for listen custom deeplink.
  • Universal Links / App Links both IOS and Anroid for listen Universal Links.

Befor use

if you are using Universal links your must be config you servr support IOS and Android handle deeplink Android to create https://youserveer.com/.well-known/assetlinks.json

[
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "com.yourdomain.app",
      "sha256_cert_fingerprints": ["YOUR_APP_SHA256_FINGERPRINT"]
    }
  }
]

IOS to create https://yourdomain.com/.well-known/apple-app-site-association

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "teamId.com.yourdomain.app",
        "paths": [ "/apple-login-callback", "/callback/*" ]
      }
    ]
  }
}

Update AppDelegate for IOS


import deeplink_listener // πŸ‘ˆ important: import your plugin module

@objc class AppDelegate: FlutterAppDelegate {

    //other


    // MARK: - Universal Link
    override func application(
        _ application: UIApplication,
        continue userActivity: NSUserActivity,
        restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
    ) -> Bool {
        DeeplinkListenerPlugin.handleUserActivity(userActivity)
        return super.application(application, continue: userActivity, restorationHandler: restorationHandler)
    }

    // MARK: - Custom URL Schemes
    override func application(
        _ app: UIApplication,
        open url: URL,
        options: [UIApplication.OpenURLOptionsKey : Any] = [:]
    ) -> Bool {
        DeeplinkListenerPlugin.handleOpenURL(url)
        return super.application(app, open: url, options: options)
    }
}

Usage

Make sure to check out examples

Installation

Add the following line to pubspec.yaml:

dependencies:
  deeplink_listener: ^1.0.4

Basic setup

The complete example is available here.

create your _linkSub  
StreamSubscription<String>? _linkSub;
String _deeplinkResult = 'Unknown';

⭐ Initial cold start

  • Get first time app never open and not active.
DeeplinkListener.getInitialLink().then((link) {
      print('[Dart] getInitialLink: $link');
      if (link != null) _handleDeepLink(link);
});

⭐ Stream for incoming links

  • Get all time when app live and in background.
 _linkSub = DeeplinkListener.linkStream.listen(
      (link) {
        print('[Dart] linkStream received: $link');
        _handleDeepLink(link);
      },
      onError: (err) {
        print('[Dart] linkStream error: $err');
      },
);

Funtion Handller

  // Example handler
  void _handleDeepLink(String link) {
    // Do something with the link (e.g., navigation)
    setState(() {
      _deeplinkResult = link;
    });
    print("Handling deep link: $link");
  }

Note Don't forget cancel _linkSub before your view dispose

@override
void dispose() {
    _linkSub?.cancel();
    super.dispose();
}
  1. Andoid Deeplink

  2. IOS Deeplink

how to run Testing in local

Make sure you config all

  1. Android can run adb by add echo 'export PATH="$PATH:/Users/nemo/Library/Android/sdk/platform-tools"' >> ~/.zprofile, your .zsrc

//Check your device has been link 
 adb devices   
//Open Custom deeplink
adb shell am start -a android.intent.action.VIEW -d "myapp://open"
//Open Universal Links
 adb shell am start -a android.intent.action.VIEW -d "link.yourdomain.com"

  1. IOS no need you just : Open browser safari
//Open Custom deeplink
myapp://
//Open Universal Links
https://link.deepershort.com

Hello everyone πŸ‘‹

If you want to support me, feel free to do so.

Thanks

============================================

αžŸαž½αžŸαŸ’αžŠαžΈ αž’αŸ’αž“αž€αž‘αžΆαŸ†αž„αž’αžŸαŸ‹αž‚αŸ’αž“αžΆπŸ‘‹

αž”αžΎβ€‹αž’αŸ’αž“αž€β€‹αž…αž„αŸ‹β€‹αž‚αžΆαŸ†αž‘αŸ’αžšβ€‹αžαŸ’αž‰αž»αŸ† αžŸαžΌαž˜β€‹αž’αŸ’αžœαžΎβ€‹αžŠαŸ„αž™β€‹αžŸαŸαžšαžΈ ,

αžŸαžΌαž˜αž’αžšαž‚αž»αžŽ