Package com.whatsapp.otp.android.sdk
Class WhatsAppOtpIncomingIntentHandler
java.lang.Object
com.whatsapp.otp.android.sdk.WhatsAppOtpIncomingIntentHandler
Class to handle intents coming from WhatsApp
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetDebugSignalFromWhatsAppIntent(android.content.Intent intent) ExtractDebugSignalfrom WhatsApp IntentgetOtpCodeFromWhatsAppIntent(android.content.Intent intent) Extract code from WhatsAppIntentbooleanisIntentFromWhatsApp(android.content.Intent intent) Check if theintentis from WhatsApp app by checking its pending intent creator packagebooleanisIntentFromWhatsApp(android.content.Intent intent, WhatsAppClientType... clientType) Check if theintentis from WhatsApp app by checking its pending intent creator packagevoidprocessOtpCode(android.content.Intent intent, Consumer<String> onCodePresent, BiConsumer<WhatsAppOtpError, Exception> errorHandler) Process code using theonCodePresentif the code is present or handle error usingerrorHandlerif the code is not present, if the intent is not valid, or if something else doesn't work out while extracting the code from theintent.voidprocessOtpDebugSignals(android.content.Intent intent, Consumer<DebugSignal> debugSignalConsumer, BiConsumer<WhatsAppOtpError, Exception> errorHandler) Process debug signals using thedebugSignalConsumerif debug signals are present or handle the error usingerrorHandlerif the debugs signals are not present.
-
Constructor Details
-
WhatsAppOtpIncomingIntentHandler
public WhatsAppOtpIncomingIntentHandler()
-
-
Method Details
-
processOtpCode
public void processOtpCode(android.content.Intent intent, Consumer<String> onCodePresent, BiConsumer<WhatsAppOtpError, Exception> errorHandler) Process code using theonCodePresentif the code is present or handle error usingerrorHandlerif the code is not present, if the intent is not valid, or if something else doesn't work out while extracting the code from theintent.- Parameters:
intent- whatsapp intentonCodePresent- function that receives the code if the code is presenterrorHandler- function to handle error scenarios
-
getOtpCodeFromWhatsAppIntent
Extract code from WhatsAppIntent- Parameters:
intent- WhatsApp intent- Returns:
- the code
- Throws:
InvalidWhatsAppOtpIntentException- if intent is not from WhatsApp
-
processOtpDebugSignals
public void processOtpDebugSignals(@NonNull android.content.Intent intent, @NonNull Consumer<DebugSignal> debugSignalConsumer, @NonNull BiConsumer<WhatsAppOtpError, Exception> errorHandler) Process debug signals using thedebugSignalConsumerif debug signals are present or handle the error usingerrorHandlerif the debugs signals are not present.The debugSignalConsumer receives a
DebugSignalas a parameter which contains the key and message of the debug signal.The errorHandler gets a
WhatsAppOtpErrorand aException- if any - stating the error.- Parameters:
intent- a WhatsApp intent.debugSignalConsumer- a consumer for the debug signalerrorHandler- a consumer for handling errors that may occur while extracting the debug signal
-
getDebugSignalFromWhatsAppIntent
ExtractDebugSignalfrom WhatsApp Intent- Parameters:
intent- WhatsApp intent- Returns:
- extracted debug signal
-
isIntentFromWhatsApp
public boolean isIntentFromWhatsApp(@NonNull android.content.Intent intent) Check if theintentis from WhatsApp app by checking its pending intent creator package- Parameters:
intent- intent- Returns:
- true if the intent is from whatsapp, either com.whatsapp or com.whatsapp.w4b
-
isIntentFromWhatsApp
public boolean isIntentFromWhatsApp(@NonNull android.content.Intent intent, @NonNull WhatsAppClientType... clientType) Check if theintentis from WhatsApp app by checking its pending intent creator package- Parameters:
intent- intentclientType- client type which can be CONSUMER, BUSINESS or both- Returns:
- true if the intent is from the specified app type
-