App Open Ads constitute a distinctive ad format that caters to publishers seeking to monetize their app load screens. These ads are strategically positioned to be exhibited when your users switch to your app and may be terminated at any point.
Create an app and App Open ad placement on the Pangle platform
The main steps to integrate App Open ads are:
Please set the host app icon when initializing the Pangle SDK
Tips: Please follow the code below to set the app icon, otherwise the icon image won't be displayed in the App open ad.
var config = new PAGConfig.Builder()
...
.SetAppIconName(...)
...
.Build();
PAGOpenAdRequest is an Ad Loading Manager. It is recommended to be the member variable of the Activity. This class can configure the load timeout period.
xxxxxxxxxx
var request = new PAGAppOpenRequest
{
//set timeout
Timeout = 5000
};
//request an ad
_appOpenAd?.Load(request);
Use the method of PAGAppOpenAd to load the ad, and register the callback.
//create PAGAppOpenAd object,write the slot id
PAGAppOpenAd _appOpenAd = new PAGAppOpenAd(slotId)
{
//Set whether the callback event switches to the unity main thread, true means switching to the main thread, false means not switching, the default is true
CallbackOnMainThread = false
};
_appOpenAd.OnLoad += (() =>
{
Debug.Log("[PAGAppOpen]-[Load]:successfully");
ShowAppOpenAd();
});
_appOpenAd.OnLoadFailed += ((code, msg) =>
{
Debug.Log($"[PAGAppOpen]-[Load]:failed, code ={code}, error message = {msg}");
});
PAGAppOpenAdLoadListener | Description |
OnLoadFailed | This method is invoked when an ad fails to load. It includes an error parameter of type Error that indicates what type of failure occurred. For more information, refer to the ErrorCode section. |
OnLoad | This method is executed when an ad material is loaded successfully. |
Ad event callbacks need to be registered before displaying an ad. Each method in the event callback corresponds to an event in the ad lifecycle.
xxxxxxxxxx
_appOpenAd.OnAdShowed += (() => { Debug.Log("[PAGAppOpen]-[interaction]:show"); });
_appOpenAd.OnAdClicked += (() => { Debug.Log("[PAGAppOpen]-[interaction]:click"); });
_appOpenAd.OnAdDismissed += (() => { Debug.Log("[PAGAppOpen]-[interaction]:dismiss"); });
PAGAppOpenAdInteractionListener | Description |
onAdShowed | This method is invoked when the ad is displayed, covering the device's screen. |
onAdClicked | This method is invoked when the ad is clicked by the user. |
onAdDismissed | This method is invoked when the ad disappears. |
An instance of the PAGAppOpenAd object will be returned when the ad is loaded successfully. Call the show()
method of PAGInterstitialAd to render the ad and it needs to pass into activity.
xxxxxxxxxx
_appOpenAd?.Show();
Destroy advertisements in time to avoid memory leaks.
xxxxxxxxxx
_appOpenAd?.DestroyAd();
Now you have finished the integration. If you wanna test your apps, make sure you use test ads rather than live, production ads. The easiest way to load test ads is to use test mode. It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging.
Refer to the How to add a test device? to add your device to the test devices on the Pangle platform.