Search Unity

Audience Network Facebook

Discussion in 'Web' started by Ghoustleader, Mar 24, 2019.

  1. Ghoustleader

    Ghoustleader

    Joined:
    Aug 8, 2016
    Posts:
    1
    please i finish my game and i want to add the ads of the audience network facebook for Instant Games
    but i can't, i add 2 plugins (facebook and audience network ) i create tow function LoadInterstitial() and ShowInterstitial() but i can't show the ads in my game when the player lose or winning how i can solve this probelem.

    Code :

    public void LoadInterstitial()
    {
    // 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.
    this.interstitialAd = new InterstitialAd("Interstitial Placement ID");

    this.interstitialAd.Register(this.gameObject);

    // Set delegates to get notified on changes or when the user interacts with the ad.
    this.interstitialAd.InterstitialAdDidLoad = (delegate() {
    Debug.Log("Interstitial ad loaded.");
    this.isLoaded = true;
    this.didClose = false;
    });
    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.");
    });

    this.interstitialAd.interstitialAdDidClose = (delegate() {
    Debug.Log("Interstitial ad did close.");
    this.didClose = true;
    if (this.interstitialAd != null) {
    this.interstitialAd.Dispose();
    }
    });

    #if UNITY_ANDROID
    /*
    * Only relevant to Android.
    * This callback will only be triggered if the Interstitial activity has
    * been destroyed without being properly closed. This can happen if an
    * app with launchMode:singleTask (such as a Unity game) goes to
    * background and is then relaunched by tapping the icon.
    */
    this.interstitialAd.interstitialAdActivityDestroyed = (delegate() {
    if (!this.didClose) {
    Debug.Log("Interstitial activity destroyed without being closed first.");
    Debug.Log("Game should resume.");
    }
    });
    #endif

    // Initiate the request to load the ad.
    this.interstitialAd.LoadAd();
    }

    // Show button
    public void ShowInterstitial()
    {
    if (this.isLoaded) {
    this.interstitialAd.Show();
    this.isLoaded = false;
    }
    }


    public void StartGame()
    {

    LoadInterstitial ();
    ShowInterstitial ();


    //Code Games
    }
     
  2. CheerfulDev

    CheerfulDev

    Joined:
    Jul 16, 2017
    Posts:
    5
    i have the same problem, i dotn't know what i miss in the code