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
challengeMode
received inonSelectSecretQuestionAnswer
orgetSecretAnswer
event. - 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 2 months ago