SMS OTP
📲 SMS OTP Challenge (getSmsOTP + setSmsOTP)
This guide explains how to implement the SMS OTP challenge in the REL-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 REL-ID SDK to continue the onboarding or authentication process.
📘 Use Case
- Called after
getSmsOTP
is 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
attemptsLeft
to guide retry behavior. - Only call
setSmsOTP
once per challenge. - There is no
resendSmsOTP
API. Resend is managed by backend logic if available.
Updated 3 months ago