Skip to main content
Version: 1.0

2.1.1.1.3 Deep Link Method

Overview

The Deep Link Verification process allows users to verify their phone numbers by interacting with an external application, such as Telegram or WhatsApp, and then returning to your app to complete the verification.

Get started

Use verifyPhoneNumberWithDeepLink with these parameters:

  • deepLink: URL that directs users to the external app for verification.
  • verificationKey: Unique key provided by your backend to ensure verification integrity.
  • callBackListener: Callback interface to handle success and failure cases:
    • onSuccess: Triggered on successful verification, returning a token to retrieve the user's phone number.
    • onFail: Triggered if verification fails, providing error details including type and message.
kotlin
VerifySpeed.verifyPhoneNumberWithDeepLink(
"DEEP_LINK", // deep link provided by your backend
"VERIFICATION_KEY", // unique key provided by your backend
true, // redirect to the store if the app is not installed
object : VerifySpeedListener { // callback listener for success and failure cases
override fun onSuccess(token: String) {
Log.d("VerifySpeed", "Token: $token")
}
override fun onFail(error: VerifySpeedError) {
Log.d("VerifySpeed", "Error: ${error.message}")
}
}
)

Handling app resumption

When users return from the external app, call notifyOnResumed() to complete the verification process:

kotlin or java
VerifySpeed.notifyOnResumed()

Example

For complete implementation examples, see:

Jetpack Compose:

Android Views:

tip

When testing the example project, you'll need to integrate with your backend using these recommended request/response structures (which you can modify as needed).

tip

Search for keywords TIP if you want to know how to implement Deep Link Verification.

Best Practices

  1. Use a dedicated activity for deep link verification

    • Create a separate activity (e.g., MessageActivity) specifically for handling deep link verification instead of using your MainActivity
    • Benefits of this approach:
      • Prevents unnecessary notifyOnResumed() calls when there's no active verification in progress
      • Provides better lifecycle management for the verification flow
      • Activity can self-destruct after successful verification
    • Implementation considerations:
      • Launch this dedicated activity when starting verification
      • Implement onResume() to call VerifySpeed.notifyOnResumed()
      • Close the activity after verification completes or fails
  2. Activity Lifecycle Management

    • Always call VerifySpeed.notifyOnResumed() in the onResume() method of your verification activity
    • Ensure proper cleanup by finishing the activity after verification completes
    • This prevents verification state from persisting longer than necessary
tip

Using a dedicated activity for deep link verification is highly recommended as it provides better control over the verification flow and prevents potential issues with notifyOnResumed() being called at inappropriate times.

Implementation example

Here's an example of how to implement the dedicated activity pattern:

  1. Define the Activity in AndroidManifest.xml
<activity
android:name=".ui.message.MessageActivity"
android:exported="false"
android:theme="@style/Theme.Example" />
  1. Implement the Dedicated Verification Activity
kotlin
class MessageActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// Get the method from intent
val method = intent.getStringExtra("method") ?: return finish()

// Set activity for VerifySpeed
VerifySpeed.setActivity(this)

// UI implementation
...
}

override fun onResume() {
super.onResume()
// Notify when activity is resumed for Deep Link Process
VerifySpeed.notifyOnResumed()
}
}
  1. Launch the Verification Activity
kotlin
val intent = Intent(context, MessageActivity::class.java).apply {
putExtra("method", method.methodName)
}
context.startActivity(intent)

This implementation follows the best practices by:

  • Using a dedicated activity for verification
  • Properly handling lifecycle events
  • Cleaning up after verification completes
  • Managing the verification state effectively
note

Remember to destroy the activity after verification completes to prevent unnecessary notifyOnResumed() calls in subsequent app launches.