SMS OTP
š² SMS OTP Challenge (getSmsOTP + setSmsOTP)
This guide explains how to implement the SMS OTP challenge in the Ditto ID SDK using the getSmsOTP and setSmsOTP APIs.
š„ getSmsOTP Event
getSmsOTP EventThe SDK triggers this event when an SMS OTP is required from the user during onboarding or authentication.
š§¾ Sample Payload
{
"userID": "test_user",
"verificationKey": "s8m88a",
"attemptsLeft": 1,
"challengeResponse": {
"status": {
"statusCode": 100,
"statusMessage": "Success."
},
"session": {
"sessionType": 0,
"sessionID": "1XMX8J72K2NZMPGUX2NPIP6HICAT1FKCF7PVCJA4VDZNFWMVGS"
},
"additionalInfo": {
"idvUserRole": "USER",
"currentWorkFlow": "FirstTimeUserActivation",
"isMTDDownloadOnly": 0
},
"challengeInfo": [
{
"key": "Response label",
"value": "OTP"
},
{
"key": "description",
"value": "Enter one time password"
},
{
"key": "SDK_CHLNG",
"value": "NO"
},
{
"key": "SDK_CHLNG_MODE",
"value": "NA"
},
{
"key": "ENABLE_RESEND_ACCESS_CODE",
"value": "true"
}
]
},
"error": {
"longErrorCode": 0,
"shortErrorCode": 0,
"errorString": "Success"
}
}
š¤ setSmsOTP API
setSmsOTP APIThe setSmsOTP API is used to submit the SMS-based OTP that was collected from the user in response to the getSmsOTP challenge event.
This method completes the OTP verification step and allows the Ditto ID SDK to continue the onboarding or authentication process.
š Use Case
- Called after
getSmsOTPis triggered. - Sends the OTP entered by the user back to the SDK for validation.
š± Platform-specific Usage
š React Native
rdnaClient.on(RdnaClient.getSmsOTP, (response) => {
RdnaClient.setSmsOTP("123456", (res) => {
console.log("SMS OTP result:", res);
});
});š£ Flutter
rdnaClient.on(RdnaClient.getSmsOTP, (response) {
rdnaClient.setSmsOTP("123456");
});š§© Cordova
document.addEventListener("getSmsOTP", function(response) {
const otp = prompt("Enter SMS OTP");
com.uniken.rdnaplugin.RdnaClient.setSmsOTP(
() => console.log("OTP submitted"),
(err) => console.error("Error", err),
["123456"]
);
});š iOS (Objective-C)
- (void)getSmsOTP:(NSString *)userID
verificationKey:(NSString *)verificationKey
attemptsLeft:(int)attemptsLeft
response:(RDNAChallengeResponse *)response
error:(RDNAError *)error {
[rdnaInstance setSmsOTP:@"123456"];
}š¤ Android (Java)
@Override
public void getSmsOTP(String userID, String verificationKey, int attemptsLeft, RDNAChallengeResponse response, RDNAError error) {
rdna.setSmsOTP("123456");
}ā
Success Response
{
"status": {
"statusCode": 100,
"statusMessage": "Success"
}
}| Code | Message | Description / Handling Recommendation |
|---|---|---|
106 | Invalid SMS OTP provided. Please try again. | Shown when an incorrect code is provided, but retry attempts are still available. Prompt user to retry. |
110 | SMS OTP has expired. | Indicates the code has timed out. Prompt the user to request or generate a new activation code. |
š Notes
- Use
attemptsLeftto guide retry behavior. - Only call
setSmsOTPonce per challenge. - There is no
resendSmsOTPAPI. Resend is managed by backend logic if available.
Updated 4 months ago
