Offerwall Integration for Unity Plugin

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

  1. Implement the Offerwall Listener
  2. Initialize the Offerwall Unit
  3. Present the Offerwall
  4. Reward the User
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. To receive these events, create an empty game object in each of your unity scenes and drag SupersonicEvents.cs into it.

Add the following code to register to the events:

public class VideoScript : MonoBehaviour {
void OnEnable() 
{
  SupersonicEvents.onOfferwallInitSuccessEvent += OfferwallInitSuccessEvent;
  
  SupersonicEvents.onOfferwallInitFailEvent += OfferwallInitFailEvent;
  
  SupersonicEvents.onOfferwallOpenedEvent += OfferwallOpenedEvent;
  
  SupersonicEvents.onOfferwallAdCreditedEvent += OfferwallAdCreditedEvent;
  
  SupersonicEvents.onOfferwallClosedEvent += OfferwallClosedEvent;
  
  SupersonicEvents.onOfferwallShowFailEvent += OfferwallShowFailEvent;
  
  SupersonicEvents.onGetOfferwallCreditsFailEvent += GetOfferwallCreditsFailEvent;
  }
}
view raw

Add the following code to stop listening to the events:

public class VideoScript : MonoBehaviour {
void OnDisable() 
{
  SupersonicEvents.onOfferwallInitSuccessEvent -= OfferwallInitSuccessEvent;
  
  SupersonicEvents.onOfferwallInitFailEvent -= OfferwallInitFailEvent;
  
  SupersonicEvents.onOfferwallOpenedEvent -= OfferwallOpenedEvent;
  
  SupersonicEvents.onOfferwallAdCreditedEvent -= OfferwallAdCreditedEvent;
  
  SupersonicEvents.onOfferwallClosedEvent -= OfferwallClosedEvent;
  
  SupersonicEvents.onOfferwallShowFailEvent -= OfferwallShowFailEvent;
  
  SupersonicEvents.onGetOfferwallCreditsFailEvent -= GetOfferwallCreditsFailEvent;
  }
}

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

/**
 * Invoked when the Offerwall is prepared an ready to be shown to the user
 */ 
void OfferwallInitSuccessEvent();
/**
 * Invoked when the Offerwall does not load for the user
 */ 
void OfferwallInitFailEvent(SupersonicError error);
/**
 * 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 'showOfferwall' failure.
 */
void OfferwallShowFailEvent(SupersonicError 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 - A string object which represents the reason of 'getOffereallCredits' failure. 
  */
void GetOfferwallCreditsFailEvent(SupersonicError error);
/**
  * Invoked when the user is about to return to the application after closing 
  * the Offerwall.
  */
void OfferwallClosedEvent();
Note:  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. Initialize the Offerwall Unit

Once the Offerwall Ad Unit is initialized, you will able to call functions on it. We recommend initializing the Offerwall on application launch.

public class MyApp : MonoBehaviour {
void Start() 
  {
  Supersonic.Agent.start();
  //Set the unique id of your end user.
  string uniqueUserId = "APPLICATION_USER_ID_HERE"; 
  string appKey = "YOUR_APPLICATION_KEY";
  //Init Rewarded Video
  Supersonic.Agent.initOfferwall(appKey,uniqueUserId);
  }
}
Note: Note:
  1. appKey is the unique ID of your Application in your ironSource account.
    ironsource-platform-app-key
  2. Important! uniqueUserId is the unique ID of your end user. We support NSString from 1 to 64 characters. Common practice is to use the Apple Advertising ID (IDFA) or Google Advertising ID (GAID). Read more information on User IDs here

Step 3. Present the Offerwall

After you receive the onOfferwallInitSuccessEvent you are ready to show the Offerwall to your user.

When you want to show the Offerwall (typically done 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 
Supersonic.Agent.showOfferwall();

New! Placements for Offerwall

With ironSource’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.

Supersonic.Agent.showOfferwall("placementName");

Step 4. 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 ironSource account notifies you of user’s completions or rewards via the supersonicDidReceiveCredit 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: 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:

Supersonic.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 initOWWithAppKey.

SupersonicConfig.Instance.setClientSideCallbacks(true);
Note: 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 ironSource 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.
Supersonic Switch App to Live Mode Rewarded Video Ad Unitironsource-go-live-with-rewarded-video

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