avioli / uni_links

Flutter plugin for accepting incoming links.
BSD 2-Clause "Simplified" License
564 stars 317 forks source link

When app is killed and open from the link then initial link concept is not working #84

Open rajatjain2802 opened 4 years ago

rajatjain2802 commented 4 years ago

This is My Method :

initPlatformStateForStringUniLinks() async {
    // Attach a listener to the links stream
    _sub = getLinksStream().listen((String link) {
      if (!mounted) return;
      setState(() {
        _latestLink = link ?? 'Unknown';
        print("Latest Link : $_latestLink");
        _latestUri = null;
        try {
          if (link != null) {
            _latestUri = Uri.parse(link);

            if (_latestLink.contains("lead-details")) {
              print("Lead Detail");
              leadID = _latestUri.pathSegments.elementAt(1);
              if (AppConfig.of(context).userModel.rememberDigest.isNotEmpty) {
                navigatorKey.currentState.push(new MaterialPageRoute(
                  builder: (BuildContext context) {
                    return new LeadDetailsScreen(
                      leadId: leadID,
                      isFromDeepLinking: true,
                    );
                  },
                ));
              }
            }
          }
        } on FormatException {}
      });
    }, onError: (err) {
      if (!mounted) return;
      setState(() {
        _latestLink = 'Failed to get latest link: $err.';
        _latestUri = null;
      });
    });
}

==

And initPlatformStateForStringUniLinks() this method called in initstate() in main.dart file

aseembajajcs commented 3 years ago

Any updates on this issue?

cmoellerffo commented 3 years ago

We also need this to be fixed asap !

avioli commented 3 years ago

@rajatjain2802 you don't seem to be using getInitialLink nor getInitialUri... the stream is for future links, while an app instance is already running in the background (or the foreground).

ritaamro commented 3 years ago

I was facing the same issue when tapping a Push notification resulted in cold-starting the iOS application, not sure this is what you're facing, but check how I fixed mine here #129