Android
This page will guide you through the integration of Revlum in your android app
1. Add Grade Dependency
In your settings.gradle (or build.gradle if using an older Android Studio project), add the dependency with the Maven URL to our SDK. For example::
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven {
url = uri("https://sdk-revlum-android.s3.amazonaws.com/")
content {
includeGroup("com.revlum")
}
}
google()
mavenCentral()
}
}
In the module-level build.gradle, add the dependency to the Revlum SDK:
dependencies {
//...other dependencies...
implementation("com.revlum:offerwall:1.0.1")
}
2. Initialize the SDK
At any point before launching the Offerwall activity, set up the Offerwall configuration by calling the RevlumOfferwallSdk.configure method and provide it with the required API key and context (ideally an instance of Application), along with optional parameters like userId and subId. If you do not provide a user ID, the SDK will automatically generate one. If a user ID is set (either manually or automatically), it will be used as long as a new user ID is not provided manually..
import com.revlum.offerwall.RevlumOfferwallSdk
...
RevlumOfferwallSdk.configure(
apiKey = "myapikey1234567890",
context = applicationContext,
subId = null,
userId = "myuserid"
)
3. Internet permission
Before launching the Offerwall activity or checking for a reward, ensure that you have added the internet permission in your AndroidManifest.xml file, as the SDK requires internet access to function properly.
<uses-permission android:name="android.permission.INTERNET" />
4. Show the offerwall
Launch the Offerwall activity by calling the RevlumOfferwallSdk.launch method, providing it the context.
import com.revlum.offerwall.RevlumOfferwallSdk
...
RevlumOfferwallSdk.launch(context = context)
If you're using Jetpack Compose, you can get the context through the LocalContext class.
import androidx.compose.ui.platform.LocalContext
...
val context = LocalContext.current
if not, pass it your current activity or fragment.
5. Check reward
Check for a reward by using the checkReward function. It requires a reward callback (which will return a reward value, which will be 0 if there is no reward, and a list of conversions), and an error callback.
import com.revlum.offerwall.RevlumOfferwallSdk
...
RevlumOfferwallSdk.checkReward(
onError = {
Log.d("StartScreen", "checkReward onError $it")
},
onCheckReward = {
Log.d("StartScreen", "checkRewards onCheckReward ${it.reward}")
}
)
Updated 2 months ago