I have integrated Facebook audience network for showing ads in my game.
I show Interstitial Ads. Showing ads in ANDROID platform Successfully done but when i run my game on IOS it's getting crash while showing ads.
-My script for load and show Interstitial ads
using UnityEngine;
using AudienceNetwork;
using AudienceNetwork.Utility;
public class InterstitialAdScene : MonoBehaviour
{
public static InterstitialAdScene instance;
private InterstitialAd interstitialAd;
private bool isLoaded;
#pragma warning disable 0414
private bool didClose;
#pragma warning restore 0414
private void Awake()
{
instance = this;
AudienceNetworkAds.Initialize();
// AdSettings.AddTestDevice("38dab032-c36a-44e9-a7ed-f39eeef3093e");
if (!isLoaded)
{
LoadInterstitial();
}
}
// Load button
public void LoadInterstitial()
{
Debug.Log("Loading interstitial ad...");
// Create the interstitial unit with a placement ID (generate your own on the Facebook app settings).
// Use different ID for each ad placement in your app.
#if UNITY_ANDROID
interstitialAd = new InterstitialAd("917812518650022_917813945316546");
#endif
#if UNITY_IOS
interstitialAd = new InterstitialAd("377269886512141_377270299845433");
#endif
interstitialAd.Register(gameObject);
// Set delegates to get notified on changes or when the user interacts with the ad.
interstitialAd.InterstitialAdDidLoad = delegate ()
{
Debug.Log("Interstitial ad loaded.");
isLoaded = true;
didClose = false;
string isAdValid = interstitialAd.IsValid() ? "valid" : "invalid";
};
interstitialAd.InterstitialAdDidFailWithError = delegate (string error)
{
// Debug.Log("Interstitial ad failed to load with error: " + error);
};
interstitialAd.InterstitialAdWillLogImpression = delegate ()
{
// Debug.Log("Interstitial ad logged impression.");
};
interstitialAd.InterstitialAdDidClick = delegate ()
{
// Debug.Log("Interstitial ad clicked.");
};
interstitialAd.InterstitialAdDidClose = delegate ()
{
// Debug.Log("Interstitial ad did close.");
didClose = true;
if (interstitialAd != null)
{
interstitialAd.Dispose();
}
};
// Initiate the request to load the ad.
interstitialAd.LoadAd();
}
// Show button
public void ShowInterstitial()
{
if (isLoaded)
{
interstitialAd.Show();
isLoaded = false;
}
else
{
Debug.Log("Ad not loaded. Click load to request an ad.");
}
}
void OnDestroy()
{
// Dispose of interstitial ad when the scene is destroyed
if (interstitialAd != null)
{
interstitialAd.Dispose();
}
Debug.Log("InterstitialAdTest was destroyed!");
}
}
-getting this crash while showing ad:
Terminating app due to uncaught exception 'FBFinalClassViolationException', reason: 'FBInterstitialAd is a final class and cannot be subclassed. FBInterstitialAd'
Please help me for this i don't know how to fixed it.
Thanks