This post is part of the Power of PushAuth™ blog series. The first post of the series was a comprehensive guide to push authentication. The next three posts of the series comprise an end-to-end sample implementation of PushAuth in a simple user login flow. The tutorial breakdown is as follows:
- Web Server tutorial
- iOS Mobile App tutorial
- Android Mobile App tutorial (this post)
The tutorial in this post builds on the web server from the first tutorial. With your web server set up and running, you now need a mobile app to receive and respond to notifications. This post will help you build the Android mobile app to do so; then you will be able to leverage the power of PushAuth for login requests!
Setup
To follow this tutorial, you will need:
- An Android device running Android 7.0 or higher
- A computer with Android Studio 4.0 installed
- JDK 8 installed (we recommend using jabba)
Step 1: Cloning the Project
The sample Android mobile app code for this project is provided in the pushauth-sample-app-android GitHub repository. Clone this repo to your local machine:
Open Android Studio, select “Open an existing Android Studio project,” and select the directory of the cloned repository. It should look something like this:
Step 2: Set up Firebase Cloud Messaging (FCM)
Firebase Cloud Messaging (FCM) is the platform used to send notifications to Android devices. You will first need to set up Firebase in your app by following the instructions at https://firebase.google.com/docs/android/setup. After doing this, ensure that a google-services.json file is present under the app/ directory of the project in Android Studio.
Next, navigate to the Firebase project settings of your app in your browser and select the “Cloud Messaging” tab. The token labeled “Server key” is what you will need to provide to UnifyID in the next section, so copy that value.
Step 3: Providing Push Credentials to UnifyID
Now you have the Firebase Cloud Messaging (FCM) server key copied; you will provide it to UnifyID so that PushAuth can send push notifications to the sample app on your phone. You’ll provide this value in your project’s dashboard. Follow the instructions in the Developer Portal docs to do so. After you’ve done this, your project dashboard will indicate they are successfully uploaded:
Step 4: Building the Project
Now, back to Android Studio. Make sure that your Android device is plugged into your computer, has developer tools and USB debugging enabled, and is available in the top center of Android Studio. Also, make sure that the google-services.json file is located under the app/ directory of the project.
With everything set up, click the green triangle or press Control+R to run the app. The following screen should appear on your device:
Step 5: Mobile App Settings
You now have all the values necessary for configuration! Tap the gear icon in the top right corner of the sample app’s Configuration screen. For SDK key, enter your UnifyID project’s SDK key value from the Dashboard. The User string should be the same value that you used when creating a user in the web server tutorial, e.g., “Morgan.” If these values do not match, you will not be able to respond to push notifications in the login flow successfully.
After setting those values and clicking “Confirm,” the app is ready to receive your PushAuth login requests! The app will remain on the “Waiting for PushAuth requests” page until it receives a PushAuth authentication request.
Now you can go through the full login flow by entering your username and password on the login page, respond to the notification received by this app on your phone, and be successfully logged into the website.
That’s it! Now you have a simple login flow that integrates PushAuth. Stay tuned for the rest of the posts in the series. Make sure to share this post and reach out to us if you have any questions, comments, or suggestions!
To learn about Prove’s identity solutions and how to accelerate revenue while mitigating fraud, schedule a demo today.
Keep reading
Developers know identity verification is an essential element of effective digital onboarding and the customer lifecycle. Choosing the right one can feel like navigating a maze of features and complexity.
In an age where our smartphones have become almost like extensions of ourselves, the identity assurance achieved through smartphone possession and data is a natural evolution.
Rodger Desai, CEO of Prove, a leading identity verification solution provider, offers a unique perspective on the rising fraud in the gig economy, advocating for robust digital identity verification as a key defense mechanism.