Step 2 - Enable Email Verification

Find the “Verification emails” block and click on Settings. The “Verification emails” block looks like this:

Click on Verify User Email. It is right here:

Fill in the empty fields and modify the ones that have already been filled based on your preferences.

Click on the SAVE button.

Step 3 - Sign Up

The two fundamental attributes of ParseUser class are username and password. There’s a third special attribute that you should also set, i.e. the email.
To implement Sign Up with Email Verification, you will use the same method which you used to implement the basic user registration. But this time, instead of making an intent to the next page, you will ask the user to verify his or her email to login.

Once the verification process is completed, the user is automatically added to Parse Dashboard and its emailVerified Boolean attribute is set as false. Email verification is must as only you’ll be allowed to let your users access your app entirely.

To make SignUpActivity work, follow these steps:

Import into your SignUpActivity, in addition to the dependencies imported in Step 1:

1
2

importcom.parse.ParseException;importcom.parse.SignUpCallback;

To implement user registration, simply use the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

try{// Reset errors<InsertUserEmailHere>.setError(null);<InsertUserPasswordHere>.setError(null);// Sign up with ParseParseUseruser=newParseUser();user.setUsername(<InsertUsernameHere>);user.setPassword(<InsertUserPasswordHere>);user.setEmail(<InsertUserEmailHere>);user.signUpInBackground(newSignUpCallback(){@Overridepublicvoiddone(ParseExceptione){if(e==null){ParseUser.logOut();alertDisplayer("Account Created Successfully!","Please verify your email before Login",false);}else{ParseUser.logOut();alertDisplayer("Error Account Creation failed","Account could not be created"+" :"+e.getMessage(),true);}}});}catch(Exceptione){e.printStackTrace();}

In the example project, this code is placed inside a SIGN UP button callback.
Also, username and password are caught using Edit Texts.

You may add your own code to verify if the email address is valid before setting it in the front end.
Finally, you may add your own code to provide feedback.

It’s interesting to add an additional method to display Alert Dialogs and make the process look more professional. Here’s how you can do this:

Step 4 - Log in

To implement Log In with Email Verification, you will use the same method which you used to implement the basic user registration. But this time, you will check the emailVerified boolean before granting further access to the user.

Note: the user actually logs in when the function ParseUser.logInInBackground() is called. But he can’t access the app entirely until the email verification is done, because of a Session object which is created in the database. So it’s important to use ParseUser.logout() every time the user who hasn’t verified his email tries to access the application unsuccessfully, in order to not leave Sessions opened.

To make LoginActivity work, follow these steps:

Import into your LoginActivity, in addition to the dependencies imported in Step 1: