Is there a way to know that a user clicked on the verification link?

限于喜欢 提交于 2019-12-04 11:36:38

firebaser here

There is no client-side callback that triggers when the user clicks the verification link.

We've seen a feature request to trigger Cloud Functions when a user verifies their email address, but no updates on whether/when that will come. (Also see: Cloud Functions for Firebase - action on email verified)

The best I can think of now is to call User.reload() occasionally to get the updated properties.

You can add a continueUrl when sending an email verification to redirect back to your app: https://firebase.google.com/docs/auth/web/passing-state-in-email-actions

var actionCodeSettings = {
  url: 'https://www.example.com/?email=' + 
       firebase.auth().currentUser.email
};
firebase.auth().currentUser.sendEmailVerification(actionCodeSettings)
  .then(function() {
    // Verification email sent.
  });

This will show a continue button after verification. You can use it to go back to the app or to some page where you can notify the original page via real time database of the verification.

You can make sure whether the user clicked on the verification link by trying to get the user id for the current user from Firebase, when it's empty, then this means that the user clicked on verification link and a new user has been created.

FirebaseAuth mAuth = FirebaseAuth.getInstance();
if(!mAuth.getCurrentUser().getUid().equals("")){
// the user clicked on the verification link.
// a new user has been created.
}
else{
// the user didn't click on the verification link.
// No user created.
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!