Open Reset Password Link within Flutter mobile App

Viewed 145

In my Flutter Mobile App authentication is handled by my own server API

Currently I have an ask reset password feature in my mobile app which sends a reset password link to the user’s email inbox.

This link opens a web page inside the user’s browser, where they enter a new password.


Instead of opening a web page I’d like this link to open my mobile app at specific reset password route + persist & provide to that route the reset password code

What kind of attributes should my link have to achieve this behavior & provide the reset code to the route ?

Is there a way to achieve any of this without using Firebase Dynamic Links ?

What do I need to setup inside my Flutter App to achieve any of this logic ?

I’m using BLoC state management.

1 Answers

You have to use deep link and while creating the deep link if on mobile open the app and navigate to that page and if app is unavailable then take the user to the web page.. Deep linking is not connected to firebase auth.. Both are different services and deep link will work even without firebase auth.

EDIT when creating deep link add the extra data in the link like the following

Future<Uri> createDynamicLink(String id) async {
      final DynamicLinkParameters parameters = DynamicLinkParameters(
        uriPrefix: 'https://your.page.link',
        link: Uri.parse('https://{your URL}.com/?id=$id'),//<----id=some value is custom data that you wish to pass
        androidParameters: AndroidParameters(
          packageName: 'your_android_package_name',
          minimumVersion: 1,
        ),
        iosParameters: IosParameters(
          bundleId: 'your_ios_bundle_identifier',
          minimumVersion: '1',
          appStoreId: 'your_app_store_id',
        ),
      );
      var dynamicUrl = await parameters.buildUrl();

      return dynamicUrl;
  }

To retrieve this

final PendingDynamicLinkData data = await FirebaseDynamicLinks.instance.getInitialLink();
Uri deepLink = data?.link;

if (deepLink != null) {
  if (deepLink.queryParameters.containsKey('id')) {
     String id = deepLink.queryParameters['id'];     
     Navigator.of(context).push(MaterialPageRoute(builder: (context) => SomeScreen(id: id);
  }
}

you can check this for reference https://blog.devgenius.io/firebase-flutter-dynamic-links-step-by-step-guide-630402ee729b

Related