Get Auto Read OTP

For WhatsApp and SMS, you can auto-read the OTP if the user’s WhatsApp account or SIM is on the same device. You will get the OTP in the HeadlessResponse itself with OTP_AUTO_READ responseType.

private void onHeadlessCallback(@NonNull final HeadlessResponse response) {
    if (response.getStatusCode() == 200) {
        switch (response.getResponseType()) {
            case "OTP_AUTO_READ":
                // Automatically read OTP from the message inbox SMS or WhatsApp
                final String otp = response.getResponse().optString("otp");
                // Pre fill the OTP and call the verify OTP function automatically
                break;
            // other cases...
        }
        JSONObject successResponse = response.getResponse();
    } else {
        // Handle error
        String error = response.getResponse().optString("errorMessage");
    }
}
Ensure your app package name and app hash are whitelisted with the Auto Read Template for both SMS and WhatsApp. Know more