Exemplo n.º 1
0
        private static void ConfigureMicrosoftInterstitalAd()
        {
            Microsoft.Advertising.WinRT.UI.InterstitialAd interstitialAd = new Microsoft.Advertising.WinRT.UI.InterstitialAd();
            interstitialAd.AdReady           += (s, e) => { RaiseActionOnAppThread(WSANativeInterstitialAd.AdReady, WSAInterstitialAdType.Microsoft); };
            interstitialAd.ErrorOccurred     += (s, e) => { RaiseActionOnAppThread(WSANativeInterstitialAd.ErrorOccurred, WSAInterstitialAdType.Microsoft, e.ErrorMessage); };
            interstitialAd.Completed         += (s, e) => { RaiseActionOnAppThread(WSANativeInterstitialAd.Completed, WSAInterstitialAdType.Microsoft); };
            interstitialAd.Cancelled         += (s, e) => { RaiseActionOnAppThread(WSANativeInterstitialAd.Cancelled, WSAInterstitialAdType.Microsoft); };
            WSANativeInterstitialAd._Request += (adType, adVariant, appId, adUnitId) =>
            {
                if (adType == WSAInterstitialAdType.Microsoft)
                {
                    AppCallbacks.Instance.InvokeOnUIThread(() =>
                    {
#if UNITY_WSA_10_0
                        interstitialAd.RequestAd(adVariant == WSAInterstitialAdVariant.Display ? Microsoft.Advertising.WinRT.UI.AdType.Display : Microsoft.Advertising.WinRT.UI.AdType.Video,
                                                 appId, adUnitId);
#else
                        interstitialAd.RequestAd(Microsoft.Advertising.WinRT.UI.AdType.Video, appId, adUnitId);
#endif
                    }, false);
                }
            };
            WSANativeInterstitialAd._Show += (adType) =>
            {
                if (adType == WSAInterstitialAdType.Microsoft && interstitialAd != null && interstitialAd.State == Microsoft.Advertising.WinRT.UI.InterstitialAdState.Ready)
                {
                    AppCallbacks.Instance.InvokeOnUIThread(() =>
                    {
                        interstitialAd.Show();
                    }, false);
                }
            };
        }
Exemplo n.º 2
0
 public InterstitialAd()
 {
     _ad = new Microsoft.Advertising.WinRT.UI.InterstitialAd();
     _ad.AdReady += _ad_AdReady;
     _ad.Completed += _ad_Completed;
     _ad.Cancelled += _ad_Cancelled;
     _ad.ErrorOccurred += _ad_ErrorOccurred;
 }
Exemplo n.º 3
0
 public InterstitialAd()
 {
     _ad                = new Microsoft.Advertising.WinRT.UI.InterstitialAd();
     _ad.AdReady       += _ad_AdReady;
     _ad.Completed     += _ad_Completed;
     _ad.Cancelled     += _ad_Cancelled;
     _ad.ErrorOccurred += _ad_ErrorOccurred;
 }
Exemplo n.º 4
0
 public void Dispose()
 {
     ClearCallback(AdCallback.Cancelled);
     ClearCallback(AdCallback.Error);
     ClearCallback(AdCallback.Completed);
     ClearCallback(AdCallback.Ready);
     this._ad = null;
 }
Exemplo n.º 5
0
 public void Dispose()
 {
     ClearCallbacks(AdCallback.Cancelled);
     ClearCallbacks(AdCallback.Error);
     ClearCallbacks(AdCallback.Completed);
     ClearCallbacks(AdCallback.Ready);
     this._ad = null;
 }