1. Get your API Key
Sign up for a new developer account and create a new App. Copy your App Token to initiate the SDK.
2. Install the SDK
Add the following code above the dependencies section of your app-level build.gradle file:
repositories {
maven {
url 'https://jitpack.io'
}
}
Then add the dependency to the same file:
dependencies {
// other dependencies
implementation 'com.github.BitBurst-GmbH:bitlabs-android-library:1.2.1'
// other dependencies
}
Add following permissions to your app:
<uses-permission android:name="android.permission.INTERNET" />
3. Use the SDK
Initiate the SDK before you use it:
//Kotlin
BitLabsSDK.init(<context>, "YOUR-TOKEN", "YOUR-USER-ID");
//Java
BitLabsSDK.Companion.init(<context>, "YOUR-TOKEN", "YOUR-USER-ID");
Call the .show() function to open the Offer Wall/Direct Link
//Kotlin
BitLabsSDK.show(<context>)
//Java
BitLabsSDK.Companion.show(<context>);
Optional Setup:
Use .hasSurveys() to check if a survey is available for the user
//Kotlin
BitLabsSDK.hasSurveys(
// NOTE: the offerwall can be shown without checking for surveys first
object: Listener<Boolean> {
override fun onResponse(response: Boolean) {
BitLabsSDK.show(this)
}
},
object: ErrorListener {
override fun onError(error: Error) {
Log.e("BitLabs", error.toString())
}
}
)
//Java
BitLabsSDK.Companion.hasSurveys(
// NOTE: the offerwall can be shown without checking for surveys first
response -> BitLabsSDK.Companion.show(this),
error -> Log.e("BitLabs", error.toString())
)
Use .onReward() to check receive callbacks to reward the user. We highly recommend using server-to-server callbacks instead!
//Kotlin
BitLabsSDK.onReward(
object: RewardListener<Float> {
override fun onReward(payout: Float) {
Log.i("BitLabs", "Payout of: ${payout}"))
}
}
)
//Java
BitLabsSDK.Companion.onReward(
payout->Log.i("BitLabs", "Payout of: " + payout)
);
Use .setTags() to pass additional parameters to the SDK you would like to receive in your callback
//Kotlin
val tags: MutableMap<String, Any> = java.util.HashMap()
tags["my_tag"] = "new_user"
tags["is_premium"] = true
BitLabsSDK.setTags(tags)
//Java
Map<String, Object> tags = new HashMap<>();
tags.put("my_tag", "new_user");
tags.put("is_premium", true);
BitLabsSDK.Companion.setTags(tags);
4. Set up your callbacks
Setting up callbacks can be done on the dashboard. Follow the instructions and examples in our Server to Server Callback Article to properly set up callbacks.