TapResearch only supports Unity v5.0 and above.
You can download the latest version of the TapResearch Unity SDK on GitHub.
Inside the TapResearchSDK directory, you will find Tapresearch.unitypackage. You can import the package by selecting Assets > Import Package > Custom Package… through the Unity menu.
The SDK uses External Dependency Manager for Unity to integrate the native library dependencies.
If the dependency manager is already installed on your app, you can remove the Dependency Manager files when importing the SDK.
For the Android build, make sure the dependencies have been resolved by going to Assets
=> External Dependency Manager
=> Android Resolver
=> Resolve
.
For iOS, the plugin will add CocoaPods to the project and will import the dependencies in the XCode project.
Initialize the TapResearchSDK as early as possible so TapResearch can start getting surveys ready for your users. The Configure() method only needs to be called once on app launch. Also, your iOS and Android apps have different API tokens – use preproccessor directives so Unity knows which API token to use when you build your app.
using TapResearch;
#if UNITY_IOS
const String ApiToken = "ios_api_token";
#elif UNITY_ANDROID
const String ApiToken = "android_api_token";
#endif
public class MyMainController : MonoBehaviour {
public void Awake()
{
TapResearchSDK.Configure(ApiToken);
}
}
Next step will be to send a unique user identifier, please note that without a unique identifier the survey wall won't be available.
TapResearchSDK.SetUniqueUserIdentifier ("<UNIQUE_USER_IDENTIFIER>");
A placement is the allocated section in your application where you want to provide access to TapResearch's survey wall, like an action button or a list item. To create a placement, navigate to the app settings in the supplier dashboard click settings and add the placement. The placement is encapsulated by the TRPlacement object which contains the placement metadata and the method to display the survey wall.
To initialize a placement, it is best practice to call the SDK as late as possible before displaying the placement in the app. For example, you can initialize it in the Start
method
of the scene where the placement will be visible
public TRPlacement tapresearchPlacement;
void Start ()
{
TapResearchSDK.OnPlacementReady = this.OnPlacementReady;
TapResearchSDK.InitPlacement(PlacementIdentifier)
}
void OnPlacementReady(TRPlacement placement)
{
myPlacement = placement;
if (placement.PlacementCode != TRPlacement.PLACEMENT_CODE_SDK_NOT_READY)
{
if (tapresearchPlacement.IsSurveyWallAvailable)
{
//Display the placement
}
}
else
{
//Placement initialized before the SDK was ready
}
}
Notice that the survey wall may or may not be available to a specific user and it's important to check survey availability before displaying the placement.
Please note that if the placement request was fired before that SDK is ready the OnPlacementReady
will be called twice. The first time PlacementCode
will return TRPlacement.PLACEMENT_CODE_SDK_NOT_READY
indicating that the request was fired
before the SDK was ready, the second call will return the latest placement from the server.
To display the survey wall, call the ShowSurveyWall
on your TRPlacement
object.
myPlacement.ShowSurveyWall();
Please Note: A placement can only show the survey wall one time. Once the survey wall is dismissed, you'll have to initialize a new TRPlacement object if you wish to keep the placement visible in the app.
hasHotSurvey
is a placement attribute that indicates a special, high yield survey is available for this user. When this attribute is true,
the user should be shown a special call to action to encourage them to take advantage of this opportunity.
These special survey opportunities may only be available for a few minutes, so initPlacement
should be called whenever the parent view is loaded.
If you want to use Hot Survey please contact developers@tapresearch.comdevelopers@tapresearch.com.
Depending on your preferences the rewards notification will be posted to a url or will trigger an in-game game callback. Please follow the instructions below for server postback or in-game callback implementation
To opt in for server to server postbacks, navigate to the supplier dashboard. Please visit API docs to learn about postbacks integration.
#if UNITY_IOS
const String ApiToken = "ios_api_token";
#elif UNITY_ANDROID
const String ApiToken = "android_api_token";
#endif
public class MyMainController : MonoBehaviour {
public void Awake() {
TapResearchSDK.Configure (API_TOKEN);
TapResearchSDK.SetUniqueUserIdentifier ("<UNIQUE_USER_IDENTIFIER>");
}
}
Add a reward listener so we can notify you when a user completes a survey. The quantity value will automatically be converted to your virtual currency based on the exchange rate you specified in your app settings. It is important to note that this method may be called back to back if the player completed multiple surveys in one session.
public class MyMainController : MonoBehaviour {
public void Awake() {
TapResearchSDK.Configure (ApiToken);
TapResearchSDK.OnReceiveReward = this.OnReceiveReward;
}
private void OnReceiveReward(TRReward reward) {
Debug.Log ("You've earned " + reward.RewardAmount + " " + reward.CurrencyName + ". " + reward.TransactionIdentifier);
}
}
Assign a delegate if you want to be notified when the survey wall status changed
public class MyMainController : Application {
public void Start() {
TapResearch.OnSurveyWallOpened = this.OnSurveyWallOpened;
TapResearch.OnSurveyWallDismissed = this.OnSurveyWallDismissed;
}
private void OnSurveyWallOpened () {
// Stop music, timers, etc.
}
private void OnSurveyWallDismissed () {
// Start music, timer, etc.
}
}
If you wish to customise the look of the survey wall modal to fit with the rest of your game use the following:
TapResearchSDK.SetNavigationBarText ("Title");
TapResearchSDK.SetNavigationBarTextColor ("#00ffff");
TapResearchSDK.SetNavigationBarColor ("#ff7f50");
To output debug info to logcat when generating Android build use the following
#if UNITY_ANDROID
TapResearchSDK.SetDebugMode (true);
#endif
using TapResearch
. All the SDK classes are under the TapResearch
namespace.TapResearch
to TapResearchSDK
. e.g. TapResearch.Configure
is now TapResearchSDK.Configure
TapResearch.cs
Assets/Plugins/Android/tapresearch.aar
Assets/Plugins/Android/unitybridge.aar
Assets/Plugins/Android/play-services-ads-lite-10.2.6
Assets/Plugins/Android/play-services-basement-10.2.6
Assets/Plugins/iOS/TapResearchSDK.framework
The following methods and callbacks were removed from the SDK
TapResearch.isSurveyAvailable
TapResearch.isSurveyAvailable(identifier)
TapResearch.ShowSurvey()
TapResearch.ShowSurvey(String identifier)
TapResearch.OnSurveyModalOpened
TapResearch.OnSurveyModalDismissed
TapResearch.OnSurveyAvailable
TapResearch.OnSurveyAvailable
In Assets > Plugins > Android please delete the following:
<activity android:name="com.tapr.internal.c.TRSurveyActivity"...
from AndroidManifest.xmlBefore you are ready to go live, it is important that your reward callback is working properly. Navigate to your dashboard and click the Add Devices button. Add a device name and your Google Advertising ID. Now, when you enter our survey flow through your app, you will be able to complete a test survey and receive a test reward when you re-open your app.
If placement.IsSurveyWallAvailable
is false please reference the android or ios integration guides for further steps
Please send all questions, concerns, or bug reports to developers@tapresearch.com