Unity SDK

This page will guide you through the integration of our Unity SDK into your app for iOS and Android.

Account Set-Up and retrieving your API Key

Before we can get started with implementing the SDK, you should retrieve your API Key for your integration from the BitLabs Dashboard. If you haven't created an account yet, you can do so here and follow the instructions for the dashboard starting with Sign up & Set up.

Installing the BitLabs SDK

You can download the latest version of our Unity SDK from the Unity Asset Store.

Initiating the SDK

You will need to initiate the SDK before you can use it. You can do so with the following code.

// Initiating the SDK
// Start is called before the first frame update
void Start()
{
   BitLabs.init("YOUR_TOKEN", "YOUR_USER_ID");
}

This is where you will need the API key from the dashboard, as you will need to replace "YOUR-TOKEN" with it. For "YOUR-USER-ID", you will need to dynamically insert the user id for each app user. Make sure the id used here is unique and that it does not change, as the user's profile will be stored under this id.

Using the SDK

Show BitLabs to the user

Now it's time to use the BitLabs SDK so that your users can start taking surveys. Call the .show() function to open the Offer Wall/Direct Link. BitLabs will show up and the user will see qualifications or surveys.

BitLabs.show();

Theoretically, this is all you have to do. Anything below is optional but can improve the user experience.

Check if there's something to do for the user

You can use .hasSurveys() to check if a survey is available for the user. This function will return true whenever there's a survey or a qualification question available for the user. If there's, it will return true.

🚧

Currently Android Only

This function currently only works for Android devices. We are working on bringing it to iOS as well.

// Check for available Surveys (Android Only)
// Set the name of the GameObject you would like to receive the feedback
BitLabs.setHasSurveys(gameObject.name);

// Create a receiver Method
public void OnHasSurveys (string surveyAvailable){
       Debug.Log("BitLabs Unity OnHasSurveys: " + surveyAvailable);
}

Client Side Callbacks

🚧

Currently Android Only

Client-Side Callbacks currently only work for Android devices. We are working on bringing it to iOS as well.

You can use .onReward() to check to receive callbacks to reward the user. We highly recommend using server-to-server callbacks instead! Please do not use this in apps where the user can withdraw real currency, as it might be exploitable.
However, if your app stores user data locally and does not sync with a server, this would be an option to still use BitLabs to reward your users.

// SDK Callbacks (Optional)
// Set the name of the GameObject you would like to receive the feedback
BitLabs.setOnReward(gameObject.name);

// Create a receiver Method
public void OnReward (string payout){
       Debug.Log("BitLabs Unity OnReward: " + payout);
}

.setTags() - Add Tags to receive in your callbacks

You can use .setTags() to pass additional parameters to the SDK you would like to receive in your callback.

// Additional Callback Tags
BitLabs.appendTag("userType", "new");
BitLabs.appendTag("isPremium", "false");

Your next Step

You have now implemented BitLabs with your project. If you haven't done it already, it is time to configure server-to-server callbacks and the look and feel of your app.