Search Unity

Heyzap HZInterstitialAd.AdDisplayListener stops triggering

Discussion in 'Scripting' started by Defero, Nov 27, 2015.

  1. Defero

    Defero

    Joined:
    Jul 9, 2012
    Posts:
    200
    Hi,

    i'm trying to integrate Heyzap adds into the game, which work almost perfectly. I'm having one issues for the last two days, that i can not solve. At the moment i'm trying this on android, but i expect the same issues on ios.

    Heyzap documentation (callback): https://developers.heyzap.com/docs/unity_sdk_advanced

    When i register the callback (delegate) to Heyzap, it works fine. But only in 2 scenes (menu and level select). I have an empty pre-load scene at the start of the game, before the actual Menu load. There is where i create and add the listener.
    For levels i am using MadLevel Manager level loader with the Asynch option (even though i'm using free version of unity).

    Whenever i get in the game (some level), the listener stops triggering. I've tryed re-registering it. Creating it again. I've tryed dontdestroyonload (and also adding this to the madlevel level loader, which by default deletes everything unless you explicitly say not to).


    Hope anyone has any ideas here, i've run out :confused:

    Code:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using Heyzap;
    4. using MadLevelManager;
    5.  
    6. public class Loading : MonoBehaviour {
    7.  
    8.     public HZIncentivizedAd.AdDisplayListener listener = delegate(string adState, string adTag){
    9.         Debug.Log(adState);
    10.         if ( adState.Equals("incentivized_result_complete") ) {
    11.             if(AddManager.instance != null)
    12.                 AddManager.instance.VideoFinished();
    13.             HZIncentivizedAd.Fetch();
    14.         }
    15.         if ( adState.Equals("available") ) {
    16.             if(AddManager.instance != null)
    17.                 AddManager.instance.VideoIsLoaded();
    18.         }
    19.     };
    20.     // Use this for initialization
    21.     void Start () {
    22.         HeyzapAds.Start("supersecret", HeyzapAds.FLAG_NO_OPTIONS);
    23.  
    24.         //HeyzapAds.ShowMediationTestSuite();
    25.         HZIncentivizedAd.Fetch();
    26.         createHeyzapListener();
    27.  
    28.         MadLevel.LoadLevelByName("MainMenu");
    29.     }
    30.  
    31.     void createHeyzapListener(){
    32.         HZIncentivizedAd.SetDisplayListener(this.listener);
    33.     }
    34. }