4
votes

I was thinking of making an iOS app using Firebase, and i wanted to know how to verify users email id who sign up for my iOS app? So that only those users who emails are verified can be users of my iOS application.

2

2 Answers

7
votes

You can use the sendEmailVerificationWithCompletion: method to send the verification email and when a user is logged in you can use the emailVerified property to check the verification stat, as it is defined here...

https://firebase.google.com/docs/reference/ios/firebaseauth/interface_f_i_r_user#instance-method-summary

So you can decide what actions can an unverified user do like request the verification again...

0
votes

In my app I did like this

        [[FIRAuth auth] signInWithEmail:emailTxt.text
                               password:pwdStr
                             completion:^(FIRUser *user, NSError *error) {
                                 // ...
                                 NSLog(@"User: %@\nUserEmail:%@\nError:%@",user.uid,user.email,error);
                                 NSLog(user.isEmailVerified ? @"Verified = Yes" : @"Verified = No");
                                 [[NSUserDefaults standardUserDefaults] setObject:user.uid forKey:@"userid"];


                                 if(error == nil){
                                     if (user.isEmailVerified) {


                                         self.ref = [[FIRDatabase database] reference];
                                         NSString *userID = [FIRAuth auth].currentUser.uid;


                                         [[_ref child:[NSString stringWithFormat:@"users/user/%@",userID]] observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot * _Nonnull snapshot) {

                                             // Get user value
                                             NSLog(@"%@",snapshot.value);
                                             // ...



                                         } withCancelBlock:^(NSError * _Nonnull error) {
                                             NSLog(@"%@", error.localizedDescription);
                                         }];


                             }];