Once you have created surveys in the PVP web interface, you must retrieve and display the surveys within your mobile app.
There are 2 types of surveys you can set up, and these will be retrieved in different ways:
These surveys are returned in the
BRScanResults.qualifiedSurveys property contingent on the receipt data that was scanned meeting the criteria you set up when you created the survey.
You must have the
BRScanOptions.validatePromotions property enabled for triggered surveys to be returned in the scan results)
These surveys are returned in the callback to
-[BRScanManager getSurveysWithCompletion:] which you can call at any time.
Once you have retrieved one or more
BRSurvey objects through one of the above methods, you can display them using our prepackaged survey controller or with your own custom UI.
Using the Prepackaged Controller
Initiate the survey by calling
-[BRScanManager startSurvey:fromViewController:withCompletion:]and pass in the
BRSurveyobject that you would like to display
The completion will be called when the user has completed the survey (or cancalled out of it). Assuming the user did not cancel, the user’s responses will be contained in that same
To inspect the user’s responses, iterate over each
BRSurvey.questionsand for each question, inspect the
BRSurveyQuestion.userResponseproperty which is of type
BRSurveyResponseconsists of either an array of selected indexes (for multiple choice questions) or a string that holds the user’s resposne to a free text question.
Creating a Custom UI
You can display a survey from start to finish with your own custom UI by simply iterating over the
BRSurvey.questionsarray and displaying the appropriate controls for each question. The text of the question is in the
BRSurveyQuestionhas a type. Currently only two types are supported:
If the question is multiple choice, the choices will be found in
BRSurveyQuestion.answerswhich is an array of
BRSurveyAnswerobjects. Additionally, whether the question allows the user to select multiple answers is controlled by the
BRSurveyAnswerobject has only a single property called
textwhich is the text to display for that answer choice
When the user has finished a question by making a selection or entering free text, you must create a new
BRSurveyResponseobject and populate it with the user’s response (which will either be a string or an array of indexes of the answers selected) and attach it to the current question via its
At this point you would call
-[BRSurveyQuestion getNextQuestionIndex]. The reason for this is that some surveys can be non-linear, for example if the user answers A to question 1, they move on to question 2 but if they answer B, they move on to question 3. Therefore you call this method to determine the index of the next
BRSurveyQuestionyou should show. A return value of
-1indicates there are no further questions
Once the user completes the survey, you must call
-[BRScanManager submitSurveyResults:]to finalize the survey