This guide walks you through what is required on your Android app in order to perform a PhoneCheck using the IDlayr Android SDK. It covers:
- What you need before you begin implementation
- Install IDlayr Android SDK
- How to implement into my app?
- Try the Verify App
- Resources
1. Before You Begin
To fully understand the functionality required to create a PhoneCheck in this guide, you will need to carry out some initial steps, such as creating an account, a project, and retrieving your workspace credentials. You'll also need to have an understanding of the workflow for a PhoneCheck to be successfully carried out.
The first step is to Setup Your Environment. This page walks you through what parts are required, such as installing the IDlayr CLI and creating a project.
The second step is to gain more of an understanding of how the PhoneCheck works. The Integration Guide provides a step by step guide on the workflow of a PhoneCheck, and which devices need to act at what points of the workflow.
2. Install IDlayr Android SDK
The IDlayr Android SDK requires a minimum API level of 24 (Android 7.0), and the compile level needs to be API 36 (Android 16) or later.
The IDlayr Android SDK is distributed privately. To get access:
- Contact us at [email protected]
- We will qualify your use case and issue an entitlement token
- You will receive setup instructions along with your entitlement token
By using the SDK, you agree to the SDK Licence Terms.
3. How to implement into my app?
Importing and Initializing the SDK
Before proceeding, be sure to sync your project for these new dependencies to be installed.
Note: There is no need to manually initialise the SDK as it is automatically initialised via Android ContentProvider.
Define an instance of the IDlayr SDK:
val sdk = IDlayrSDK.getInstance()
Reachability
The Reachability API is a feature that enables applications to check whether the SIM card within a user's device is on a network that IDlayr has connectivity to.
The IDlayr Android SDK has functionality built in to call the reachability API; to use this, first obtain a coverage access token from your backend, then call the following:
val sdk = IDlayrSDK.getInstance()val resp = sdk.openWithDataCellularAndAccessToken(URL(reachabilityUrl),accessToken,false)
If the mobile network operator is supported by IDlayr then a JSON object is returned similar to the example below:
{"network_id": "23410","network_name": "O2 UK","country_code": "GB","products": [{"product_id": "PCK","product_name": "PhoneCheck"}]}
However, if it isn't supported, then an error is returned in JSON format.
Call your backend server to create PhoneCheck
As described in the Integration guide step 1 is to create a PhoneCheck. This step is where your mobile application needs to call your backend server with the input telephone number, or the backend needs to look up the telephone number for the user that is trying to be authenticated. Your backend server then makes a POST request to IDlayr's PhoneCheck API. If successful, the PhoneCheck API will return a response with the check_id and a unique check_url. Your backend server needs to return this check_url to the mobile device.
Open Check URL to process PhoneCheck
Step 2 of the integration guide is to process the PhoneCheck. This step is where the mobile application makes a GET request to the check_url provided in the previous step. The mobile device application then needs to follow all redirects, then on the last redirect, the JSON response will contain a code. This code will be used next.
val result: JSONObject = sdk.openWithDataCellular(URL(checkUrl), false)
Call Backend server to complete PhoneCheck
Step 3 of the integration guide is to complete the PhoneCheck. This step is where the mobile application makes a POST request to your backend server with the check_id and the code. Your backend server then makes a PATCH request to /phone_check/v0.2/checks/{check_id} with the JSON body below to complete the PhoneCheck process:
[{"op": "add","path": "/code","value": "{check_code}"}]
Finally, your backend server would need to return a success or failure response to your mobile application to allow the user of this application to proceed.
4. Try the Verify App
You can download our sample application called Verify App for either Android or iOS to try out our product. The Verify App demonstrates the PhoneCheck flow end-to-end, allowing you to see how the verification process works on a real device.