简体   繁体   中英

Flutter + Firebase: how to send email verification

I tried to read online and can't find an answer on how to use the sendSignInLinkToEmail()

In particular I'm interested in what actionCodeSettings is and what value it should have. Ty in advance.

Future verificationEmail(email) async {
  try { 
     FirebaseAuth.instance.sendSignInLinkToEmail(
                                      email: email,
                                      actionCodeSettings: null
      } catch (err) { 
          print(err);
            }
}
                               

[NEW FORMAT]

_firebaseAuthInstance.sendSignInLinkToEmail(
    email: "rocky_balboa@example.com,
    actionCodeSettings: ActionCodeSettings(
        url: "https://example.page.link/cYk9",
        androidPackageName: "com.example.app",
        iOSBundleId: "com.example.app",
        handleCodeInApp: true,
        androidMinimumVersion: "16",
        androidInstallApp: true),
  );

[DEPRECATED] (yeah, already...)

FirebaseAuth.instance.sendSignInLinkToEmail(
      email: "example@example.com",
      actionCodeSettings: ActionCodeSettings(
        url: "https://example.web.app",
        android: {
          'packageName': "com.example.example",
          'installApp': true,
          'minimumVersion': '12'
        },
        iOS: {
          'bundleId': "com.example.example",
        },
        handleCodeInApp: true,
      ),
    );

It looks like email link sign-in is not too well documented yet in the brand new Flutter/Firebase documentation .

In cases like that I recommend looking at the equivalent Firebase documentation for Android. In this case the documentation on sending an authentication link to the user's email address seems to have what you need. You'll need to create an ActionCodeSettings object and pass that into the call to sendSignInLinkToEmail .

I tried to read online and can't find an answer on how to use the sendSignInLinkToEmail()

In particular I'm interested in what actionCodeSettings is and what value it should have. Ty in advance.

Future verificationEmail(email) async {
  try { 
     FirebaseAuth.instance.sendSignInLinkToEmail(
                                      email: email,
                                      actionCodeSettings: null
      } catch (err) { 
          print(err);
            }
}
                               

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM