deeplink_listener
Features
deeplink_listener :
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 {
if DeeplinkListenerPlugin.handleUserActivity(userActivity) {
return true
}
return false
}
// MARK: - Custom URL Schemes
override func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
if DeeplinkListenerPlugin.handleOpenURL(url) {
return true
}
return false
}
Usage
Make sure to check out examples
Installation
Add the following line to pubspec.yaml:
dependencies:
deeplink_listener: ^1.0.5
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();
}
Deeplink Config See
how to run Testing in local
Make sure you config all
- 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"
- 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
============================================
αα½ααααΈ α’αααααΆααα’ααααααΆπ
ααΎβα’αααβα ααβααΆααααβαααα»α ααΌαβααααΎβαααβααααΈ ,
ααΌαα’ααα»α