Offerwall Integration for Unity Plugin

Get up and running with the Offerwall Ad Unit in 3 easy steps:

Before you start Make sure you have correctly integrated the ironSource Unity Plugin. Integration is outlined here.

Step 1. Implement the Offerwall Listener

The ironSource Unity Plugin fires several events to inform you of ad availability.

Add the following code to register to the events:

void OnEnable() 
{
   IronSourceEvents.onOfferwallClosedEvent += OfferwallClosedEvent;
   IronSourceEvents.onOfferwallOpenedEvent += OfferwallOpenedEvent;
   IronSourceEvents.onOfferwallShowFailedEvent += OfferwallShowFailedEvent;
   IronSourceEvents.onOfferwallAdCreditedEvent += OfferwallAdCreditedEvent;
   IronSourceEvents.onGetOfferwallCreditsFailedEvent += GetOfferwallCreditsFailedEvent;
   IronSourceEvents.onOfferwallAvailableEvent += OfferwallAvailableEvent;
}

The Plugin will notify the Listener of all possible events listed below:

/**
* Invoked when there is a change in the Offerwall availability status.
* @param - available - value will change to YES when Offerwall are available. 
* You can then show the video by calling showOfferwall(). Value will change to NO when Offerwall isn't available.
*/
void OfferwallAvailableEvent(bool canShowOfferwall);
/**
 * Invoked when the Offerwall successfully loads for the user.
 */ 
void OfferwallOpenedEvent();
/**
 * Invoked when the method 'showOfferWall' is called and the OfferWall fails to load.  
*@param desc - A string which represents the reason of the failure.
 */
void OfferwallShowFailedEvent(IronSourceError error);
/**
  * Invoked each time the user completes an offer.
  * Award the user with the credit amount corresponding to the value of the ‘credits’ 
  * parameter.
  * @param dict - A dictionary which holds the credits and the total credits.   
  */
void OfferwallAdCreditedEvent(Dictionary<string,object> dict){
  Debug.Log ("I got OfferwallAdCreditedEvent, current credits = "dict["credits"] + "totalCredits = " + dict["totalCredits"]);
}
/**
  * Invoked when the method 'getOfferWallCredits' fails to retrieve 
  * the user's credit balance info.
  * @param desc -string object that represents the reason of the  failure. 
  */
void GetOfferwallCreditsFailedEvent(IronSourceError error);
/**
  * Invoked when the user is about to return to the application after closing 
  * the Offerwall.
  */
void OfferwallClosedEvent();{
}
Note:
ironSource provides an error code mechanism to help you understand errors you may run into during integration or live production. See the complete guide here.

Step 2. Present the Offerwall

When you want to show the Offerwall (typically after a user clicks on some in-app button), you do so by calling the following method in your application activity:

//show offerwall when user clicks the offerwall button 
IronSource.Agent.showOfferwall();

New! Placements for Offerwall

With LevelPlay‘s Ad Placements, you can customize and optimize the Offerwall experience. This tool enables you to present the Offerwall to your users in various places, i.e. in your in-app store, between levels, in the main menu,  etc. You can use the below function to define the exact Placement to show the Offerwall. Navigate to the Ad Placement document for more details.

IronSource.Agent.showOfferwall("placementName");

Step 3. Reward the User

ironSource supports two methods to reward your users. Select one of the following:

  1. Server-Side Callbacks
  2. Client-Side Callbacks

Method 1: Server-Side Callbacks

The default setting in your LevelPlay account notifies you of user’s completions or rewards via the ironSourceDidReceiveCredit callback within the client of your app. Alternatively, you can turn on server-to-server callbacks to receive notifications to your back-end server. Once you select server-to-server callbacks you will not receive client-side notifications.

We recommend turning on server-to-server callbacks for Offerwall instead of client-side callbacks, as the authenticity of the callback can be verified. With server-to-server callbacks, you will have better control over the rewarding process as the user navigates out of your app to complete the offer.

Note:
  • If you turn on server-to-server callbacks , remember not to reward the user more than once for the same completion.
  • We will fire a server-to-server callback to the selected location with an Event ID which is the unique identifier of the transaction. For us to know you’ve granted the user, you must respond to the callback with [EVENT_ID]:OK anywhere within the HTTP payload of the callback.
  • To utilize server-to-server callbacks, see here.

Method 2: Client-Side Callbacks

  • Proactive Polling API

You may call the function getOWCredits at any point during the user’s engagement with the app. You will then receive information on the user’s total credits and any new credits the user has earned.
See Step 1 for instructions on how to implement the protocol and receive callbacks for the following method:

IronSource.Agent.getOfferwallCredits();

  • Automatic Client-Side Events

You can receive client-side events automatically within your application by registering to the Offerwall listener and setting the use of client-side callbacks. Setting automatic client-side callbacks will make sure that you’re notified about the user’s credit status at specific points in the Offerwall’s lifecycle. To do so:

Important! This code MUST be implemented before calling the init.

IronSourceConfig.Instance.setClientSideCallbacks(true);
Note:  If you are using automatic client-side events, we recommend adding the proactive polling method and checking the user’s reward status on app launch, upon in-app store entry and in the case a user opened the Offerwall, ardently verifying every 5 minutes after the user closes the Offerwall to ensure you don’t miss the latest update on the user’s rewards.

Done!
You are now all set to deliver Offerwall Ad Units in your application.

First Time Integration Tip

If this is a new integration for your application, your app will by default be in ‘Test Mode‘ on your LevelPlay dashboard. While your app is in Test Mode, the ironSource SDK will print more logs to the console in order to provide greater visibility into the SDK processes. To test your ad inventory, set up your Test Devices. Until you turn on live ad inventory, you will receive test campaigns that don’t generate revenue. Make sure to select Go Live! on the Ad Units page when your app is ready for live ad inventory.

ironsource-go-live-with-rewarded-video


What’s Next?
Follow our integration guides to integrate additional Ad Units: