/// <summary>
 /// Shows the interstitial ad if it is ready.
 /// It is recommended that you have at least a 60 second gap between ads
 /// </summary>
 /// <param name="adType">The type of ad to show</param>
 public static void ShowAd(WSAInterstitialAdType adType)
 {
     if (!_unityEditor)
     {
         _InterstitialAdShow(adType.ToString());
     }
 }
        /// <summary>
        /// Initialise the interstitial ad for the specified provider
        /// </summary>
        /// <param name="adType">The ad network to initialise</param>
        /// <param name="appId">Your apps id</param>
        /// <param name="adUnitId">Your apps ad unit id (plcaement id for Vungle)</param>
        public static void Initialise(WSAInterstitialAdType adType, string appId, string adUnitId)
        {
            if (!_unityEditor)
            {
                switch (adType)
                {
                case WSAInterstitialAdType.AdDuplex:
                    _adDuplexAppId    = appId;
                    _adDuplexAdUnitId = adUnitId;
                    break;

                case WSAInterstitialAdType.Microsoft:
                    _msAppId    = appId;
                    _msAdUnitId = adUnitId;
                    break;

                case WSAInterstitialAdType.Vungle:
                    _vungleAppId       = appId;
                    _vunglePlacementId = adUnitId;
                    break;
                }

                _InterstitialAdInitialise(AdReadyCallback, CancelledCallback, CompletedCallback, ErrorOccurredCallback);
            }
        }
        /// <summary>
        /// Requests an interstitial ad from the server.
        /// The AdReady event will fire when the request completes successfully.
        /// Only needs to be called once for Vungle ads (ads will be automatically fetched from then on)
        /// </summary>
        /// <param name="adType">The type of ad to request</param>
        /// <param name="adVariant">The variant to request - "Display" for banner interstitial, "Video" for video interstitial. ONLY relevant to Microsoft ads, otherwise specify "Video"</param>
        public static void RequestAd(WSAInterstitialAdType adType, WSAInterstitialAdVariant adVariant)
        {
            if (!_unityEditor)
            {
                switch (adType)
                {
                case WSAInterstitialAdType.AdDuplex:
                    _InterstitialAdRequest(adType.ToString(), adVariant.ToString(), _adDuplexAppId, _adDuplexAdUnitId);
                    break;

                case WSAInterstitialAdType.Microsoft:
                    _InterstitialAdRequest(adType.ToString(), adVariant.ToString(), _msAppId, _msAdUnitId);
                    break;

                case WSAInterstitialAdType.Vungle:
                    _InterstitialAdRequest(adType.ToString(), adVariant.ToString(), _vungleAppId, _vunglePlacementId);
                    break;
                }
            }
        }
Example #4
0
 private static void RaiseActionOnAppThread(Action <WSAInterstitialAdType, string> action, WSAInterstitialAdType adType, string errorMessage)
 {
     if (action != null)
     {
         AppCallbacks.Instance.InvokeOnAppThread(() =>
         {
             action(adType, errorMessage);
         }, false);
     }
 }