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'sios/Info.plist
to enable external app linking.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tg</string>
<string>whatsapp</string>
</array>
Initializing deep link processor
To start, initialize an instance of DeepLinkProcessor:
redirectToStore
(optional): Settrue
(default) to redirect users to the app store if Telegram or WhatsApp is not installed.
final deepLinkProcessor =
VerifySpeed.instance.initializeDeepLinkProcessor(redirectToStore: true);
Verifying Phone Numbers with Deep Link
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 atoken
to retrieve the user's phone number.onFailure
: Callback triggered if verification fails, providingerror
details including type and message.
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.
await deepLinkProcessor.notifyResumed();
Example
For a complete implementation, see the example project on GitHub, and deep link section for more details.
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).
Search for keywords TIP
if you want to know how to implement Deep Link Verification.
Best Practices
- Use a Dedicated StatefulWidget
- Create a separate StatefulWidget for handling deep link verification
- Implement
WidgetsBindingObserver
for tracking app lifecycle - Initialize
DeepLinkProcessor
ininitState
and clean up indispose
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();
}
}
}
Using a dedicated StatefulWidget prevents unnecessary notifyResumed
calls when there's no active verification in progress.