uni_links icon indicating copy to clipboard operation
uni_links copied to clipboard

getInitialLink and getInitialUri will return null on some devices

Open joaopmarquesini opened this issue 5 years ago • 3 comments

I have an app and until now two users reported that they aren't able to login (My app uses uni_links to get the response from OAuth). after sending these users a custom build to debug the issue via sentry, I found that they were getting the getInitialLink as null. In the majority of the userbase the app and uni_links works just fine (~10k users). What I could find that these users share is that they are on Android and that the link was being called from chrome. I wasn't able to find a way to reproduce the bug properly in my setup. All that I could find out until now is that they use other apps that uses deeplinks (non flutter apps) and they work properly. the pattern that I'm using right now for my app is luzinha://login?code=########################

joaopmarquesini avatar Apr 30 '19 23:04 joaopmarquesini

I'll investigate. Thanks for reporting.

avioli avatar May 02 '19 03:05 avioli

Thanks. I will continue to try to find out what could be causing this and report if I get any new info.

joaopmarquesini avatar May 02 '19 14:05 joaopmarquesini

For me getInitialLink and getInitialUri are always null on ios, even if same code returns correct values for android.

I was able to access the values using streams as a workaround, see the documentation at https://pub.dev/packages/uni_links#-readme-tab-:

import 'dart:async';
import 'dart:io';

import 'package:uni_links/uni_links.dart';

// ...

  StreamSubscription _sub;

  Future<Null> initUniLinks() async {
    // ... check initialLink

    // Attach a listener to the stream
    _sub = getLinksStream().listen((String link) {
      // Parse the link and warn the user, if it is not correct
    }, onError: (err) {
      // Handle exception by warning the user their action did not succeed
    });

    // NOTE: Don't forget to call _sub.cancel() in dispose()
  }

// ...

RobinManoli avatar Oct 29 '19 07:10 RobinManoli