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 theBRSurvey
object 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
BRSurvey
object.To inspect the user’s responses, iterate over each
BRSurveyQuestion
inBRSurvey.questions
and for each question, inspect theBRSurveyQuestion.userResponse
property which is of typeBRSurveyResponse
A
BRSurveyResponse
consists 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.questions
array and displaying the appropriate controls for each question. The text of the question is in theBRSurveyQuestion.text
propertyEach
BRSurveyQuestion
has a type. Currently only two types are supported:BRSurveyQuestionTypeOpenEnded
BRSurveyQuestionTypeMultipleChoice
If the question is multiple choice, the choices will be found in
BRSurveyQuestion.answers
which is an array ofBRSurveyAnswer
objects. Additionally, whether the question allows the user to select multiple answers is controlled by theBRSurveyQuestion.multipleAnswers
propertyEach
BRSurveyAnswer
object has only a single property calledtext
which 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
BRSurveyResponse
object 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 nextBRSurveyQuestion
you should show. A return value of-1
indicates there are no further questionsOnce the user completes the survey, you must call
-[BRScanManager submitSurveyResults:]
to finalize the survey