Email OTP
š„ getEmailOTP Event
getEmailOTP EventThe getEmailOTP event is triggered when the Ditto ID SDK requests an Email-based OTP challenge during onboarding or device activation. Your application must collect the email OTP from the user and respond using setEmailOTP.
š§¾ Sample Payload
{
"userID": "testuser",
"verificationKey": "pkn35f",
"attemptsLeft": 3,
"challengeResponse": {
"status": {
"statusCode": 100,
"statusMessage": "Success."
},
"session": {
"sessionType": 0,
"sessionID": "example-session-id"
},
"challengeInfo": [
{ "key": "Response label", "value": "OTP" },
{ "key": "description", "value": "Enter one time password" }
]
},
"error": {
"longErrorCode": 0,
"shortErrorCode": 0,
"errorString": "Success"
}
}š¤ setEmailOTP API
The setEmailOTP API is used to submit the SMS-based OTP that was collected from the user in response to the getEmailOTP 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 getEmailOTP is triggered.
- Sends the OTP entered by the user back to the SDK for validation.
š± Platform-specific Usage
React Native
rdnaClient.on(RdnaClient.getEmailOTP, (response) => {
RdnaClient.setEmailOTP("123456", (res) => {
console.log("OTP result:", res);
});
});Flutter
rdnaClient.on(RdnaClient.getEmailOTP, (response) {
rdnaClient.setEmailOTP("123456");
});Cordova
document.addEventListener("getEmailOTP", function(response) {
const otp = prompt("Enter Email OTP");
com.uniken.rdnaplugin.RdnaClient.setEmailOTP(
() => console.log("OTP submitted"),
(err) => console.error("Error", err),
["123456"]
);
});iOS (Objective-C)
- (void)getEmailOTP:(NSString *)userID
verificationKey:(NSString *)verificationKey
attemptsLeft:(int)attemptsLeft
response:(RDNAChallengeResponse *)response
error:(RDNAError *)error {
[rdnaInstance setEmailOTP:@"123456"];
}Android (Java)
@Override
public void getEmailOTP(String userID, String verificationKey, int attemptsLeft, RDNAChallengeResponse response, RDNAError error) {
rdna.setEmailOTP("123456");
}ā
Success Response
{
"status": {
"statusCode": 100,
"statusMessage": "Success"
}
}ā Error Scenarios
| Code | Message | Description / Handling Recommendation |
|---|---|---|
106 | Invalid Email OTP provided.Please try again. | Shown when an incorrect code is provided, but retry attempts are still available. Prompt user to retry. |
110 | Email OTP has expired. | Indicates the code has timed out. Prompt the user to request or generate a new activation code. |
š Notes
- Use
attemptsLeftto manage retry UI. - Only call
setEmailOTPonce per response cycle. - There is no
resendEmailOTP()API. Retry is managed by re-triggering the challenge if supported.
Updated 4 months ago
