-
Notifications
You must be signed in to change notification settings - Fork 1
Unity Interstitial Delegates
Mert Celik edited this page Jan 8, 2019
·
4 revisions
Please refer to InterstitialSampleScript.cs in our Unity plugin for complete implementation.
After getting the AMInterstitial instance, add the delegates with the code below:
// Assuming your AMInterstitial instance is named "interstitial"
interstitial.OnAdDidLoad += this.HandleOnAdDidLoad;
interstitial.OnAdDidFailToLoad += this.HandleOnAdDidFailToLoad;
interstitial.OnAdDidShow += this.HandleOnAdDidShow;
interstitial.OnAdDidClose += this.HandleOnAdDidClose;
interstitial.OnAdDidClick += this.HandleOnAdDidClick;
After setting the delegates, add the delegates methods as shown in example below:
private void HandleOnAdDidLoad(object sender, EventArgs args)
{
this.statusLabel.text = "Interstitial loaded.";
}
private void HandleOnAdDidFailToLoad(object sender, AMFailedToLoadEventArgs args)
{
this.statusLabel.text = "Interstitial failed to load.";
}
private void HandleOnAdDidClick(object sender, EventArgs args)
{
this.statusLabel.text = "Interstitial clicked.";
}
private void HandleOnAdDidShow(object sender, EventArgs args)
{
this.statusLabel.text = "Interstitial shown.";
}
private void HandleOnAdDidClose(object sender, EventArgs args)
{
this.statusLabel.text = "Interstitial closed.";
}
ANDROID ONLY: Callbacks are not returned on Unity thread, so if you need to interact with API functions that requires Unity thread to work, you will need to handle it different, otherwise your app might fail to call that API functions. You can check example implementation in our InterstitialSampleScript.cs. Please check the UnityThread class in our plugin for more details.