5

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.

Aristidios
  • 1,921
  • 2
  • 13
  • 24

1 Answers1

4

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

Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30
  • 2
    Not sure but this is an easier approach and i have tried it in multiple projects so suggested the same – Kaushik Chandru Aug 27 '22 at 16:17
  • I've found a better solution not involving using Firebase Dynamic Links, I will post soon ! : ) (here is the bounty for your efforts) – Aristidios Sep 08 '22 at 06:32
  • 1
    Thats great. Thank you for the bounty. I would be happy to learn a better solution. Please do share. Would be really helpful :) – Kaushik Chandru Sep 08 '22 at 06:39