Node.js

Networking to Backend

The following Kotlin functions define how the mobile client communicates with the backend server to perform a phone number verification using the Verify API. This process consists of three main steps:

  1. Starting the verification process by submitting the phone number.
  2. Checking for a silent authentication result, which happens automatically in the background.
  3. Submitting the verification code (received silently or via fallback, like SMS) to complete the verification.

Each function runs inside a coroutine and performs network operations on the IO dispatcher to avoid blocking the main thread.

Start Verification

This function initiates the verification process by sending the user's phone number to the backend. The backend then starts the verification via the Vonage Verify API and responds with two values:

  • request_id: A unique identifier for the verification request.
  • check_url: A URL that can be used to check the result of the silent authentication.

Check Silent Authentication

After initiating the verification, this function initializes the silent authentication by sending a GET request to the check_url received earlier. If the silent authentication succeeds, the server responds with a verification code (after some redirects), which can be used to complete the verification process.

Submit Code

This function submits the verification code to the backend to finalize the verification process. The backend verifies the code using the Verify API and responds with a boolean indicating whether the verification was successful.

With these functions in place, your Android app can connect to your backend to complete the phone number verification process using Vonage Verify. The next step would typically involve handling success or failure in your UI, showing appropriate messages or redirecting the user accordingly.