The OfferToro Android SDK gives Android developers an easy way to integrate the OfferToro OfferWall, Rewarded Video, Non-incent OfferWall and SurveyWall modules into their native Android apps.
Before you can integrate our SDK, you must first create a publisher account, then create an app placement.
The OfferToro Android SDK can be downloaded from your publisher account under SDK section.
Note: From SDK version 4.1.0 and on, please make sure the app monetization tool you are using is 'SDK - Android'
Please make sure the monetization tool of the app you are using matches the required monetization tool of the integration. An integration with wrong monetization tool might not work.
OfferToro SDK requires minimum Android API level 22.
To integrate the SDK into your project, please follow the simple steps described below:
Step 1. Add the OfferToroSdk to your project
OfferToroSdk-v4.6.aar file should be added to your project libs folder.
Step 2. Add following code to your Gradle file:
The following code should be added to your build.gradle file:
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation 'com.google.android.gms:play-services-ads:9.6.1'
implementation(name: 'OfferToroSdk-v4.6', ext: 'aar')
}
Note: usesCleartextTraffic should be set to true on devices having Android 9 and up in order to allow a full communication with offertoro server. This setting should be added to the application manifest file
...
android:usesCleartextTraffic="true"
...
Step 1. Initialize the OfferWall
In order to initialize OfferWall , the following parameters should be passed in initialization call: secret key, app id and user id.
The call should look similar to:
public static final String YOUR_OW_SECRET_KEY = ""; //set your value
public static final String YOUR_OW_APP_ID = ""; //set your value
public static final String YOUR_OW_USER_ID = ""; //set your value
OTOfferWallSettings.getInstance().configInit(YOUR_OW_APP_ID,
YOUR_OW_SECRET_KEY, YOUR_OW_USER_ID);
NOTES:
- APPID and SECRET_KEY can be found in your OfferToro account, under your "App Placement" settings.
- UserID, is a parameter which should be passed from your end as an id for each end user of your app. A common practice is to use the Google Advertising ID (GAID) . User IDs should be URL encoded.
You can also pass extra SubIDs by calling function configSubids after configInit function was called:
1. Create “libs” directory.
In your proj.android folder, create a folder named “libs” in this location
The call should look similar to:
/frameworks/runtime-src/proj.android/app/
2. Add the OfferToroSdk-vX.X.X.aar file into the libs folder
3. In the same folder (folder app), open the build.gradle file, then:
A. Add the following after the “android” block:
repositories {
flatDir {
dirs 'libs'
}
}
B. Add the following under dependencies:
implementation 'com.google.android.gms:play-services-ads:9.6.1'
implementation(name: 'OfferToroSdk-v4.6', ext: 'aar')
Note: OfferToroSdk-v4.6.aar is the name of the AAR file
You can find out more about this step here:
http://offertoro.com/docs/android_sdk?p=introduction
4. Make sure the minimum SDK version of your app is the same as ours.
In your gradle.properties under proj.android folder, make sure the value of PROP_MIN_SDK_VERSION=22
5. Test build. If there is a build issue, try the following in the gradle.properties file:
Change this line: PROP_MIN_SDK_VERSION=22
To this: PROP_BUILD_TYPE=ndk-build
Note: Changing this line might be detrimental to your project. Proceed with caution.
Note: NDK-Build requires the Android NDK.
6. In your app’s AppActivity.java, add the code to access the API.
a. Initialize the Offerwall
In order to initialize OfferWall , the following parameters should be passed in initialization call: secret key, app id and user id.
The call should look similar to:
public static final String YOUR_OW_SECRET_KEY = ""; //set your value
public static final String YOUR_OW_APP_ID = ""; //set your value
public static final String YOUR_OW_USER_ID = ""; //set your value
NOTES:
- APPID and SECRET_KEY can be found in your OfferToro account, under your "App Placement" settings.
- UserID, is a parameter which should be passed from your end as an id for each end user of your app. A common practice is to use the Google Advertising ID (GAID) .
You can also pass extra SubIDs by calling function configSubids() after configInit() function was called:
OTOfferWallSettings.getInstance().configSubids(“SUBID1”);
You can add a maximum of 3 SubIDs, for example:
OTOfferWallSettings.getInstance().configSubids(“SUBID1”, “SUBID2”, “SUBID3”);
b. Create OfferToro SDK instance
OfferToro SDK instances should be created in the activity by calling the following method:
OffersInit.getInstance().create(this);
c. Display the OfferWall
After being successfully initialized, OfferWall could be displayed into the app. For displaying the OfferWall showOfferWall() method should be called:
OffersInit.getInstance().showOfferWall(activity);
c. Implement OfferWall listeners
The OfferToro SDK gives a possibility to be notified of events happening in OfferWall lifecycle via OfferWall listeners.
The following listeners are available:
onOTOfferWallInitSuccess() - invoked when OfferWall is successfully initialized;
onOTOfferWallInitFail(string errorMessage) - invoked when OfferWall initialization fails and receives (@param errorMessage) describing the reason for fail;
onOTOfferWallOpened() - invoked when OfferWall is displayed;
onOTOfferWallCredited(double credits, double totalCredits) - receive user's balance (@param totalCredits) and the amount of credits the user has earned (@param credits) since the last update.
However, it is not the precise way to calculate the user's balance. For a more robust way, please use the Server-to-Server postbacks instead. The listener could also be updated at any point of time by calling getOTOfferWallCredits() method;
onOTOfferWallClosed() - invoked when OfferWall is closed.
To be notified of OfferWall events, setOfferWallListener(OfferWallListener listener) method should be called:
OffersInit.getInstance().setOfferWallListener(OfferWallListener listener);
The OfferToro SDK gives possibility to update the onOTOfferWallCredited() listener in OfferWall lifecycle at any point of time by calling getOTOfferWallCredits() method.
getOTOfferWallCredits() - updates the onOTOfferWallCredited() listener.
e. Reward the User
OfferToro SDK supports two ways to reward your users. Those are:
1. Client-side postback
2. Server-to-Server postback
Client-side postback
User's balance and the amount of credits the user has recently earned are available via onOTOfferWallCredited() listener.
The listener can be updated on demand by calling getOTOfferWallCredits() method.
Server-to-Server postback
Server to Server postbacks is a more secure way to receive notifications, in order to reward your users.
To receive Server to Server postbacks, you must define your postback URL in your App Placement under your OfferToro account