Open an app in flutter based on the url provided in the email sent for verification

Viewed 978

So I have been working on a flutter app and once the user registers through my app they are sent an email for the verification of their account. Once the url in the link is tapped they are verified. Now after their verification,the users must be redirected to the app. I looked into firebase dynamic links but in all of the articles,they were trying to share their app by generating a link. Is there a way I can implement this? Thanks in advance!

1 Answers

Use this package https://pub.dev/packages/uni_links


For getting the link when the app is started. This is the case in which your app was in the closed state.

Future<Null> initUniLinks() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      String initialLink = await getInitialLink();
      // Parse the link and warn the user, if it is not correct,
      // but keep in mind it could be `null`.
    } on PlatformException {
      // Handle exception by warning the user their action did not succeed
      // return?
    }
  }

For listening to link clicks. This is for the case when your app is already open and you click the link.

_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()
  }

Usually, you need to implement both of them together since your app may be in the closed state or open state while you click the link.

Future<Null> initUniLinks() async {
  try {
    String initialLink = await getInitialLink();
   } on PlatformException {

  }
  _sub = getLinksStream().listen((String link) {}, onError: (err) {});
}}

Related