iOS Development

flutter – Deep Hyperlinks not working in iOS (App is opening however the hyperlink shouldn’t be obtainable) however working superb in Android

Spread the love


I’m utilizing the Dynamic Linking and Deep Linking in my e-Commerce Software.
The Deep Hyperlinks when clicked on the Android Units are working superb and displaying the meant behaviour.
However when the identical hyperlink is clicked on the iOS App, the App will get opened efficiently, however the hyperlinks which is clicked shouldn’t be obtainable within the perform.

Beforehand I used to be utilizing the beneath code for listening the Deep Hyperlinks and Dynamic Hyperlinks:

In foremost.dart file:

Future<void> initUniLinks() async {
    attempt {
      // Modifications to implement the Dynamic Linking Performance.
      PendingDynamicLinkData? initialLink = await FirebaseDynamicLinks.occasion.getInitialLink();
      if (initialLink == null) {
        debugPrint('No Dynamic URI');
        last uri = await getInitialUri();
        if (uri == null) {
          debugPrint('no preliminary uri');
        } else {
          debugPrint("Deeplink URL ${uri.toString()}");
          CommonEntities.deeplinkURL = uri;
        }
      } else {
        debugPrint("Dynamic URL ${initialLink.hyperlink.toString()}");
        CommonEntities.deeplinkURL = initialLink.hyperlink;
      }
    } on PlatformException {
      // Platform messages might fail however we ignore the exception
      debugPrint('did not get preliminary uri');
    } on FormatException {
      // FormatException shall be thrown if the hyperlink was not the right format
      debugPrint('malformed preliminary uri');
    }
  }

In home_screen.dart:

Future<void> initUniLinks() async {
    // BOC to examine whether or not there may be any Dynamic Hyperlink CLicked or not.
    FirebaseDynamicLinks.occasion.onLink.pay attention((dynamicLinkData) {
      debugPrint("DynamicLink URL ${dynamicLinkData.hyperlink.toString()}");
      _callApiToPerformDeepLinking(dynamicLinkData.hyperlink.toString()); // Operate to name the API to deal with the Deep Hyperlink
    }).onError((error) {
      debugPrint(error.toString());
    });
  }

Then I discovered that we have to pay attention the hyperlinks within the iOS App utilizing the “uriLinkStream.pay attention”, so theI needed to replace the code of my home_screen.dart file and now the up to date code is as follows:

Future<void> initUniLinks() async {
    bool _isDynamicLinkFound = false;
    // BOC to examine whether or not there may be any Dynamic Hyperlink CLicked or not.
    FirebaseDynamicLinks.occasion.onLink.pay attention((dynamicLinkData) {
      debugPrint("DynamicLink URL ${dynamicLinkData.hyperlink.toString()}");
      _isDynamicLinkFound = true;
      _callApiToPerformDeepLinking(dynamicLinkData.hyperlink.toString()); // Operate to name the API to deal with the Deep Hyperlink
    }).onError((error) {
      debugPrint(error.toString());
    });
    // BOC to examine for deeplink is out there or not if no Dynamic Hyperlink is out there.
    if (!_isDynamicLinkFound) {
      // Connect a listener to the stream
      uriLinkStream.pay attention((Uri? uri) {
        debugPrint("DeepLink URL ${uri.toString()}");
        _callApiToPerformDeepLinking(uri.toString());
      }, onError: (err) {
        debugPrint(err.toString());
      });
    }
  }

After making use of the above change, not the app is opening when clicking the hyperlinks, however the hyperlink which is clicked shouldn’t be obtainable in any of the features of each recordsdata.

So is there anybody can please assist me to determine the lacking hyperlink?

Leave a Reply

Your email address will not be published. Required fields are marked *