setSecretQuestionAnswer
š setSecretQuestionAnswer API
setSecretQuestionAnswer APIThe setSecretQuestionAnswer API is used to submit secret question-answer pairs in response to the onSelectSecretQuestionAnswer event and the getSecretAnswer event. This supports one or multiple questions depending on the value of numberOfQuestionsToSet.
š„ Required Parameters
| Parameter | Description |
|---|---|
questionAndAnswer | Array of objects with question and answer keys |
challengeMode | Mode of the challenge, must be passed from the event's payload |
syncResponse (callback) | Callback invoked after submission (React Native/Cordova) |
š± Platform-specific Usage
š React Native
const qaPairs = [
{ question: "What is your nickname?", answer: "Jonny" },
{ question: "What is your dream job?", answer: "Astronaut" }
];
RdnaClient.setSecretQuestionAnswer(
JSON.stringify(qaPairs),
1, // challengeMode
(response) => {
console.log("Secret answers submitted:", response);
}
);š£ Flutter
List<RDNASecretQuestionAndAnswer> qaPairs = [
RDNASecretQuestionAndAnswer("What is your nickname?", "Jonny"),
RDNASecretQuestionAndAnswer("What is your dream job?", "Astronaut"),
];
rdnaClient.setSecretQuestionAnswer(qaPairs, 1); // 1 = challengeModeš§© Cordova
const questionAnswerList = [
{ question: "What is your nickname?", answer: "Jonny" },
{ question: "What is your dream job?", answer: "Astronaut" }
];
com.uniken.rdnaplugin.RdnaClient.setSecretQuestionAnswer(
() => console.log("Success"),
(err) => console.error("Error", err),
[JSON.stringify(questionAnswerList), 1]
);š iOS (Objective-C)
RDNASecretQuestionAndAnswer *qa1 = [[RDNASecretQuestionAndAnswer alloc] initWithQuestion:@"What is your nickname?" answer:@"Jonny"];
RDNASecretQuestionAndAnswer *qa2 = [[RDNASecretQuestionAndAnswer alloc] initWithQuestion:@"What is your dream job?" answer:@"Astronaut"];
NSArray *qaArray = @[qa1, qa2];
[rdnaInstance setSecretQuestionAnswer:qaArray challengeMode:1];š¤ Android (Java)
RDNASecretQuestionAnswer qa1 = new RDNASecretQuestionAnswer("What is your nickname?", "Jonny");
RDNASecretQuestionAnswer qa2 = new RDNASecretQuestionAnswer("What is your dream job?", "Astronaut");
RDNASecretQuestionAnswer[] qaArray = new RDNASecretQuestionAnswer[] { qa1, qa2 };
rdna.setSecretQuestionAnswer(qaArray, RDNAChallengeOpMode.MANUAL);ā Error Scenarios
| Status Code / Error Code | Description | Behavior |
|---|---|---|
106 | Invalid secret answer | SDK re-triggers getSecretQuestion if attemptsLeft > 0 |
110 | Challenge expired | Challenge fails and next workflow step is invoked |
153 | Attempts exhausted | SDK ends challenge, decides next event (e.g., lockout) |
113 / 150 | Internal error | Handle gracefully and suggest retry |
Use status.statusCode, error.shortErrorCode, and error.errorString to implement user-friendly error handling.
š§ Behavior Summary
- ā Correct Answer: Challenge completes and next event is triggered.
- ā Incorrect Answer:
- If attempts remain ā same challenge is shown again.
- If no attempts ā SDK moves on based on workflow.
š§ Notes
- Always pass the same
challengeModereceived inonSelectSecretQuestionAnswerorgetSecretAnswerevent. - Validate answers for length and input policy before submission.
- This API may be required only once per user setup (typically during onboarding or activation).
Updated 9 months ago
