Frontend callback feature is released on May 14, 2022.
Introduction
Our SDK provides a callback after closing or submitting the survey by the user. In the below code, you will see how to implement a 1flow survey callback using Observer.
- Set-up Observer:
SWIFT
swiftNotificationCenter.default.addObserver(self, selector: #selector(surveyDidFinish(notification:)), name: SurveyFinishNotification, object: nil)
Objective-C
objective-c[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(surveyDidFinish:) name:@"survey_finished" object:nil];
- Read user info to get submitted survey detail:
SWIFT
swift@objc func surveyDidFinish(notification: Notification) { if let userInfo = notification.userInfo { print("Notification userInfo: \(userInfo)") } }
Objective-C
objective-c- (void)surveyDidFinish:(NSNotification *)notification { NSDictionary *userInfo = notification.userInfo; NSLog(@"Notification userInfo: %@", userInfo); }
Demo data structure 1flow callback:
jsonExample:- { "survey_id": "XXXXXXXXXXXXX", "survey_name": "Rating Survey", "trigger_name": "fileSaved", "status": finished", "screens": [ { "question_title": "How it worked", "question_type": "checkbox", "screen_id": "XXXXXXXXXXXXX", "question_ans": [ { "answer_value": "Option 1" }, { "answer_value": "Option 2" }, { "answer_value": "Other", "other_value": "Checkbox Other" } ] }, { "question_title": "Your valuable feedback", "question_type": "text", "screen_id": "XXXXXXXXXXXXX", "question_ans": [ { "answer_value": "This is user's feedback" } ] } ] }
Fields in 1flow callback:
survey_id: string
submitted survey id
survey_name: string
submitted survey name
trigger_event_name: string
event name which triggered the survey
status: string
Status of the survey. Either of 3 below
- closed - If you close the survey in the mid then our callback return with close status.
- skipped - If the user closes the survey immediately (without submitting any answer) then our callback return with skipped option.
- finished - If the user completes the whole survey then our callback returns with finish status.
screens: Array
It will be array of all the screen and answer which containing flowing key-value pairs
- question_type - type of the question
- question_ans - array of following key-value pair
- answer_value - answer of the question
- other_value - if question type is checkbox or radio button and it contains other field, then it will be value which user have typed in other field.
- screen_id - question id
- question_title - title of the question