Home > Back-end >  Not receiving firebase dynamic link
Not receiving firebase dynamic link

Time:09-30

Currently I am doing a project that calls a secondary app and I launch the 2nd app through InAppWebView. While the 2nd app is facing the user, the inappwebview is still running and sends live update, which I am capturing to trigger events, for example like it will send payment complete, allowing me to trigger to go summary page.

The issue I am having is, I am unable to smoothly transit back to my app. So there are two ways that I found that allow me to go back to the app.

One, launch the URL using my dynamic link but this method I am unable to receive the link.

Second, to launch it through external application like chrome.

The second method works perfectly other than the fact that the screen jumps to chrome. And it continues from where I left off.

However, what I want is both, continue from where I left off and not have the jumping of the chrome. Or from what I have read the right way is to direct to the activity using intent filter. But the smooth method I am not receiving the links but the jump method I am receiving the links.

Please help T - T

CodePudding user response:

if you need to add dynamic links with firebase you can find the setup right in the docs and with the help with firebase_dynamic_links you can handle where to go inside your app and also can execute parameters from the link in the function below you make a stream that listen to any dynamic link clicked while the app in the background or foreground , the PendingDynamicLinkData is when the app terminated. the business logic and how the app interacts ups to you.

static Future<void> initDynamicLink() async {
FirebaseDynamicLinks.instance.onLink.listen((dynamicLink) async {
  if (dynamicLink.link != Uri.parse("uri")) {
    log(dynamicLink.link.queryParameters.toString());
    final Uri deepLink = dynamicLink.link;
    // you should handle the navigation or you logic here
  }
}).onError((error) {
  debugPrint("error from dynamic link Stream : : :: ${error.toString()}");
});
final PendingDynamicLinkData? initialLink =
    await FirebaseDynamicLinks.instance.getInitialLink();
try {
  if (initialLink != null) {
    log(initialLink.link.toString());
    final Uri deepLink = dynamicLink.link;
     // you should handle the navigation or you logic here
  }
} catch (e) {
  debugPrint('No deepLink found');
 }
}

don't forget to call this function in the main like this

void main()async{
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
 initDynamicLink();
}
  • Related