Offerwall Integration for Adobe Air
Get up and running with the Offerwall Ad Unit by completing a few simple steps:
- Implement the Offerwall Listener
- Present the Offerwall
- Reward the User
Make sure you have correctly integrated the ironSource Adobe Air Plugin. Integration is outlined here.
Step 1. Implement the Offerwall Listener
The ironSource Adobe Air Plugin fires several events to inform you of Offerwall Activity. To receive these events, you must implement the Offerwall EventListener:
IronSource.instance.addEventListener( "EventName", functionToCall );
- EventName = a string containing the event you want to listen to.
- functionToCall = The function to call when the event is fired.
The ironSource Adobe Air Plugin will notify your Listener of all possible events listed below:
IronSource.instance.addEventListener(“onOfferwallAvailable”, onOfferwallAvailable); IronSource.instance.addEventListener(“onOfferwallOpened”, onOfferwallOpened); IronSource.instance.addEventListener(“onOfferwallShowFailed”, onOfferwallShowFailed); IronSource.instance.addEventListener(“onOfferwallAdCredited”, onOfferwallAdCredited); IronSource.instance.addEventListener(“onGetOfferwallCreditsFailed”, onGetOfferwallCreditsFailed); IronSource.instance.addEventListener(“onOfferwallClosed”, onOfferwallClosed);
Implementation:
////Invoked when there is a change in the ad availability status. function onOfferwallAvailable(event:DataEvent):void { } //Invoked when the Offerwall is was not successfully shown. function onOfferwallShowFailed(event:DataEvent):void { } //Invoked when the user should be rewarded according to the value in the credits parameter. function onOfferwallAdCredited(event:DataEvent):void { } //Invoked if ow credits failed with error description function onGetOfferwallCreditsFailed(event:DataEvent):void { } //Invoked after the Offerwall screen has opened. function onOfferwallOpened(event:DataEvent):void { } //Invoked after the Offerwall screen has closed. function onOfferwallClosed(event:DataEvent):void { }
- ironSource provides an error code mechanism to help you understand errors you may run into during integration or live production. Extract the error data from the DataEvent object as follows:
var errorCode:String; var errorDescription:String; if(event.data){ var error:Object = JSON.parse(event.data); errorDescription = error.error_description; errorCode = error.error_code; }
See the complete description of the ironSource error codes here.
Step 2. Present the Offerwall
After you receive the onOfferwallAvailable with a true value, 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:
IronSource.instance.showOfferwall();
event.data == “true/false”
Step 3. Reward the User
ironSource supports two methods to reward your users. Select one of the following:
Method 1: 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.instance.getOfferwallCredits();
- Automatic Client-Side Events (Android Only)
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.
IronSource.instance.setIronSourceClientSideCallbacks(true);Method 2: Server-Side Callbacks
- The default setting in your ironSource account notifies you of user’s completions or rewards via the ironSourceDidReceiveCredit callback within the client of your app. Additionally, you can turn on server-to-server callbacks to receive additional notifications to your back-end server.
- If you turn on server-to-server callbacks in addition to the client-side callbacks, remember not to reward the user more than once for the same completion. ironSource will fire both the client-side callback and the server-to-server callback. You will get two notifications for each 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.
Extract the credit data from the DataEvent object as follows:
var credits:int; var totalCredits:int; var totalCreditsFlag:String; if(event.data){ var creditsData:Object = JSON.parse(event.data); credits = parseInt(creditsData.credits); totalCredits = parseInt(creditsData.totalCredits); totalCreditsFlag = creditsData.totalCreditsFlag; }
Done!
You are now all set to deliver Offerwall Ad Units in your application.
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 ironSourc 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.
Follow our integration guides to implement additional Ad Units: