InBrain Surveys Unity SDK allows to present native web view with surveys from within your Unity app and receive rewards for their completion.
Unity 2018.4.14f1+
Download latest version of InBrain Surveys Unity SDK (.unitypackage). In Unity editor right click inside Project pane and select Import package -> Custom package. Select file you've downloaded and confirm. Now InBrain Surveys Unity SDK should be ready to use.
There are some prerequisites for InBrain Surveys Unity SDK:
In Unity editor go to Window -> InBrain -> Edit Settings and enter those values in corresponding input fields.
In order to access SDK functionality InBrain singleton object required. One will be instantiated automatically after referencing its 'Instance' method for the first time. Also, provide unique user ID before calling any other methods to specify which player should receive rewards.
InBrain.Instance.Init();
InBrain.Instance.SetAppUserId(appUserId);
Set global callback that will be triggered every time when new rewards received or surveys web view dismissed.
InBrain.Instance.AddCallback(rewards => {
// process rewards...
}, result => {
// handle web view dismissal result...
});
Optionally you can specify whether to confirm received rewards automatically (by default they are not).
Check if there are any surveys available before presenting inBrain experience:
InBrain.Instance.CheckSurveysAvailability(flag =>
{
// handle result...
});
Present surveys web view with the following call:
InBrain.Instance.ShowSurveys();
There are two ways to receive rewards that user earned during surveys completion:
// Global callback will be triggered
InBrain.Instance.GetRewards();
// Provide callbacks as parameters
InBrain.Instance.GetRewards(rewards => {
// process rewards...
}, () => {
// process error...
});
Processed rewards should be confirmed in order to avoid receiving them repeatedly.
InBrain.Instance.ConfirmRewards(rewardsList);
This call should always be made following rewards data processing.
SDK provides additional means that allow surveys wall UI customization.
var statusBarConfig = new InBrainStatusBarConfig
{
StatusBarColor = Color.green,
LightStatusBarIcons = false,
HideStatusBarIos = false
};
InBrain.Instance.SetStatusBarConfig(statusBarConfig);
var statusBarConfig = new InBrainStatusBarConfig
{
StatusBarColor = Color.green,
LightStatusBarIcons = false,
HideStatusBarIos = false
};
InBrain.Instance.SetStatusBarConfig(statusBarConfig);
There is a possibility to open only one specific survey in a web view. In order to that list of available surveys should be requested first by calling a GetSurveys
method.
InBrain.Instance.GetSurveys(OnSurveysFetched);
Each recieved survey has its own id
and searchId
values that should be passed to ShowSurvey
method.
InBrain.Instance.ShowSurvey(surveyId, searchId);
Alternatively one can fetch list of available surveys that metch certain criteria (i.e. survey category) by calling the GetSurveysWithFilter
method instead.
var filter = new InBrainSurveyFilter("SURVEY_PLACEMENT_ID", new List<InBrainSurveyCategory> { InBrainSurveyCategory.SocialResearch });
InBrain.Instance.GetSurveysWithFilter(filter, OnSurveysFetched);
The plugin provides an API allowing to get active currency sale. This can be done with method GetCurrencySale
.
InBrain.Instance.GetCurrencySale(sale => {
// process currency sale...
});