The OTP Android SDK is in beta and features a simplified workflow for implementing one-tap and zero-tap authentication templates. You can learn how to use it below.
This document describes Android-only error signals that can help you debug one-tap autofill authentication templates and zero-tap authentication templates.
If your message fails the eligibility check, the one-tap autofill button will be replaced with a copy code button. In addition, there may be device or WhatsApp client settings that prevent message notifications. To help with debugging, our apps surface some error information via the com.whatsapp.OTP_ERROR
intent. In these situations you will receive an error key and message instead of the user's one-time passwords or verification code.
Note that some of these error signals will only surface if you are running WhatsApp in the Android emulator.
Key | Description |
---|---|
Emulator only | Ambiguous delivery destination There are multiple active OTP requests for the packages specified by this template, and we could not determine which package to deliver the code to. This can happen when multiple applications specified in the template’s |
| Incompatible Android version This can happen when you initiate the handshake (send the |
Emulator only | Incorrect signature hash This can happen when you initiate the handshake (send the |
| Missing handshake / Order of operations This can happen when our app receives an authentication template message with a one-tap autofill button but the handshake was not initiated. |
| OTP request expired This can happen when an authentication template that uses a one-tap autofill button is delivered to the user but more than 10 minutes (or the number of minutes indicated in the template's |
Emulator only | Message notification disabled in WA settings This can happen when you initiate the handshake (send the |
Emulator only | WA notification disabled in device level This can happen when you initiate the handshake (send the |
The error signals are delivered via broadcasted intent so you must implement BroadcastReceiver
to listen for error signals.
<receiver android:name=".app.otp.OtpErrorReceiver" android:enabled="true" android:exported="true" > <intent-filter> <action android:name="com.whatsapp.otp.OTP_ERROR"/> </intent-filter> </receiver>
Implement onReceive
and use a WhatsAppOtpIncomingIntentHandler
object to process the debug signals.
public class OtpErrorReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { WhatsAppOtpIncomingIntentHandler whatsAppOtpIncomingIntentHandler = new WhatsAppOtpIncomingIntentHandler(); whatsAppOtpIncomingIntentHandler.processOtpDebugSignals( whatsAppIntent, // your function to handle the signal (debugSignal) -> handleSignal(debugSignal), // your function to handle any error (error, exception) -> handleError(error, exception)); } }
public class OtpErrorReceiver extends BroadcastReceiver { public static final String OTP_ERROR_KEY = "error"; public static final String OTP_ERROR_MESSAGE_KEY = "error_message"; @Override public void onReceive(Context context, Intent intent) { try { PendingIntent pendingIntent = intent.getParcelableExtra("_ci_"); if (pendingIntent != null) { String packageName = pendingIntent.getCreatorPackage(); if (packageName.equalsIgnoreCase("com.whatsapp") || packageName.equalsIgnoreCase("com.whatsapp.w4b")) { String otpErrorKey = intent.getStringExtra(OTP_ERROR_KEY); String otpErrorMessage = intent.getStringExtra(OTP_ERROR_MESSAGE_KEY); // Handle errors } } } catch (BadParcelableException e) { Log.e("OtpErrorReceiver", e.getLocalizedMessage()); } } }
Whenever the WhatsApp client receives an OTP handshake intent, processes a handshake payload, or registers the handshake intent, it will log the event in the console.
Console logging is only available on Android build version 2.23.24.x or newer.
Android Console Log | Purpose |
---|---|
Level: Info Logged Message: | Indicates that a handshake intent has been received. |
Level: Warning Logged Message: | Indicates that the handshake intent did not register due to missing |
Level: Info Logged Message: | Indicates successful handshake. If you see this handshake intent registered log but also detect the Some reasons for this include:
|