Skip to main content
Version: 1.0

2.1.1.3.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

  • Initialize VerifySpeed: Follow the initialize instructions.
  • iOS Configuration: If using the deep link method, add LSApplicationQueriesSchemes to your app's ios/Info.plist to enable external app linking.
xml
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tg</string>
<string>whatsapp</string>
</array>

To start, initialize an instance of DeepLinkProcessor:

  • redirectToStore (optional): Set true (default) to redirect users to the app store if Telegram or WhatsApp is not installed.
dart
final deepLinkProcessor = 
VerifySpeed.instance.initializeDeepLinkProcessor(redirectToStore: true);

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.
  • onSuccess: Callback triggered on successful verification, returning a token to retrieve the user's phone number.
  • onFailure: Callback triggered if verification fails, providing error details including type and message.
dart
await deepLinkProcessor.verifyPhoneNumberWithDeepLink(
deepLink: 'DEEP_LINK', // deep link provided by your backend
verificationKey: 'VERIFICATION_KEY', // unique key provided by your backend
onSuccess: (token) {
log('token: $token');
},
onFailure: (error) {
log('error: ${error.message} type: ${error.type}');
},
);

Handling app resumption

When users return from the external app, call notifyResumed to complete the verification process and receive the token from the onSuccess callback.

dart
await deepLinkProcessor.notifyResumed();

Example

For a complete implementation, see the example project on GitHub, and deep link section for more details.

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 StatefulWidget
    • Create a separate StatefulWidget for handling deep link verification
    • Implement WidgetsBindingObserver for tracking app lifecycle
    • Initialize DeepLinkProcessor in initState and clean up in dispose
dart
class DeepLinkSection extends StatefulWidget {

State<DeepLinkSection> createState() => _DeepLinkSectionState();
}

class _DeepLinkSectionState extends State<DeepLinkSection>
with WidgetsBindingObserver {
late DeepLinkProcessor deepLinkProcessor;


void initState() {
super.initState();
deepLinkProcessor = VerifySpeed.instance.initializeDeepLinkProcessor();
WidgetsBinding.instance.addObserver(this);
}


void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}


Future<void> didChangeAppLifecycleState(AppLifecycleState state) async {
if (state == AppLifecycleState.resumed) {
await deepLinkProcessor.notifyOnResumed();
}
}
}
tip

Using a dedicated StatefulWidget prevents unnecessary notifyResumed calls when there's no active verification in progress.