Surveys
Once you have created surveys in the PVP web interface, you must retrieve and display the surveys within your mobile app.
Retrieving Surveys
There are 2 types of surveys you can set up, and these will be retrieved in different ways:
Triggered Surveys
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.
Note
You must have the BRScanOptions.validatePromotions property enabled for triggered surveys to be returned in the scan results)
Non-triggered Surveys
These surveys are returned in the callback to -[BRScanManager getSurveysWithCompletion:] which you can call at any time.
Displaying Surveys
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 theBRSurveyobject that you would like to displayThe 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
BRSurveyobject.To inspect the user’s responses, iterate over each
BRSurveyQuestioninBRSurvey.questionsand for each question, inspect theBRSurveyQuestion.userResponseproperty which is of typeBRSurveyResponseA
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 theBRSurveyQuestion.textpropertyEach
BRSurveyQuestionhas a type. Currently only two types are supported:BRSurveyQuestionTypeOpenEndedBRSurveyQuestionTypeMultipleChoice
If the question is multiple choice, the choices will be found in
BRSurveyQuestion.answerswhich is an array ofBRSurveyAnswerobjects. Additionally, whether the question allows the user to select multiple answers is controlled by theBRSurveyQuestion.multipleAnswerspropertyEach
BRSurveyAnswerobject has only a single property calledtextwhich is the text to display for that answer choiceWhen 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-[BRSurveyQuestion addUserResponse:]methodAt 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 nextBRSurveyQuestionyou should show. A return value of-1indicates there are no further questionsOnce the user completes the survey, you must call
-[BRScanManager submitSurveyResults:]to finalize the survey
View on GitHub