Email OTP


📥 getEmailOTP Event

The getEmailOTP event is triggered when the REL-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 REL-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

CodeMessageDescription / Handling Recommendation
106Invalid Email OTP provided.Please try again.Shown when an incorrect code is provided, but retry attempts are still available. Prompt user to retry.
110Email OTP has expired.Indicates the code has timed out. Prompt the user to request or generate a new activation code.

📌 Notes

  • Use attemptsLeft to manage retry UI.
  • Only call setEmailOTP once per response cycle.
  • There is no resendEmailOTP() API. Retry is managed by re-triggering the challenge if supported.