Android Integration

Offerwalls are in-app ads that incentivize users to take particular actions. In return, the user gets an in-app reward and the developer gets paid by the advertiser.

You can download the Sample integration from GitHub

Integration video

1. Add this to your build.gradle file

Add the below line inside the dependencies block in your build.gradle file. Once added, clean build and rebuild the project.

implementation("com.pubscale.sdkone:offerwall:1.0.11")

2. Configure proguard rules

For the SDK to work properly in release(obfuscated/minified) builds, add the following rules in your proguard-rules.pro file.

proguard-rules.pro

-keep class com.pubscale.sdkone.offerwall.** {*;}
-keep class com.pubscale.caterpillar.analytics.** {*;}
#Supporting R8 full mode
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response

3. Initializing the OfferWall

You must initialize the SDK before using the SDK. To do this, call Offerwall.init(OfferWallConfig, OfferWallInitListener) .

3.1. Parameters for init call:

  • OfferWallConfig offerWallConfig: An object to pass configuration-related info to the SDK while initializing. Refer below for how to create an object of OfferWallConfig.

  • OfferWallInitListener offerWallInitListener: A listener that informs you if the SDK initialization was successful or not. In case of failure, it will also give you a string stating the cause of the failure. This parameter is optional.

3.2. Creating OfferWallConfig object:

Create an instance of OfferWallConfig using the builder class OfferWallConfig.Builder by passing the context and your PubScale app ID.

Obtain your PubScale app ID from the PubScale Dashboard by adding your app and configuring the offerwall. Once completed, you will receive a unique 8-digit app ID.

Use sandbox environment app ID for testing purposes.

Sandbox Environment - Learn how to setup Sandbox environment

import com.pubscale.sdkone.offerwall.OfferWallConfig
..
..
val offerWallConfig = OfferWallConfig.Builder(context, "YOUR_PUBSCALE_APP_ID")
   .setUniqueId("unique_id")
   .setSandboxEnabled(false) //Change this to true to enable sandbox mode
   .build()

These are the public methods available for OfferWallConfig.Builder class:

Public Methods
Description

setUniqueId(String uniqueId)

Sets a unique id that will be used to identify the user uniquely. This will be sent back in the postback.

setSandboxEnabled(Boolean isEnabled)

Sets if the offerwall should open in the sandbox environment

setLoaderBackgroundBitmap(Bitmap bitmap)

Accepts a bitmap and uses it as the background image for the loader and offerwall top banner. Default: Black color image

setLoaderForegroundBitmap(Bitmap bitmap)

Accepts a bitmap and uses it as the foreground image for the loader and offerwall top banner. Default: App icon

setFullscreenEnabled(Boolean isEnabled)

Sets if the offerwall should open in fullscreen mode or not. This can be used in apps or games where an immersive experience is needed. Default: false

build()

Builds the config and returns OfferWallConfig instance

3.3. Making the init call:

Initialize the OfferWall SDK by calling the init function by passing the offer wall config.

OfferWall.init(offerWallConfig, object : OfferWallInitListener {
   override fun onInitSuccess() {
   }
   override fun onInitFailed(error: InitError) {
   }
})

If you need to change any config after initializing the SDK, you should destroy and re-init the SDK.

To destroy, call OfferWall.destroy()

4. Start the OfferWall

To start the offerwall, just call, OfferWall.launch(Context, OfferWallListener);

A listener can be set to listen for events fired by the Offer Wall.

import com.pubscale.sdkone.offerwall.OfferWall
import com.pubscale.sdkone.offerwall.models.OfferWallListener
import com.pubscale.sdkone.offerwall.models.Reward
..
..
..
val offerWallListener = object : OfferWallListener{

   override fun onOfferWallShowed() {
       Log.d("PSOfferwall", "Offer wall showed.")
   }

   override fun onOfferWallClosed() {
       Log.d("PSOfferwall", "Offer wall closed.")
   }

   override fun onRewardClaimed(reward: Reward) {
       Log.d("PSOfferwall", "Offer wall reward claimed.")
   }

   override fun onFailed(message: String) {
       Log.d("PSOfferwall", "onFailed: $message")
   }
}                 

onRewardClaimed callback gives you the reward amount and currency details.

To start the OfferWall, call the launch method of the OfferWall class.

import com.pubscale.sdkone.offerwall.OfferWall
import com.pubscale.sdkone.offerwall.models.OfferWallListener
..
..
OfferWall.launch(context, offerWallListener)            

5. Setup S2S callbacks

Setup the S2S callbacks to get instant updates whenever the user gets the reward. You can use this callback to reward the user in your application. Learn more.

6. Test the OfferWall

Please use the sandbox environment for testing purposes to get instant callbacks and rewards. To learn how to enable the Sandbox environment, click here.

Finally, To test the offerwall, build the application to an actual device. Check if you can launch the Offerwall and get the appropriate callbacks.

Last updated

Was this helpful?