/// <summary> /// <para> show ad</para> /// </summary> /// <param name="adType">adType, 0(WALLAD), 1(FULLSCREENPOPUPAD), 2(REWARDEDVIDEOAD)</param> /// <param name="placementID">in most cases just leave it ""</param> /// <param name="uiOrientation">invalid on UWP platform</param> public static void ShowAd(int adType, string placementID, int uiOrientation) { RunInUWPUIThread(() => { AdManager.AdKind adKind = (AdManager.AdKind)adType; Task <AdDealsPopupAd> showAdTask = AdManager.GetPopupAd(AdDealsWrapperUWP.rootPanel, adKind); showAdTask.Wait(); AdDealsPopupAd showAd = showAdTask.Result; showAd.AdClosed += AdClosed_Tap; // OPTIONAL. This is triggered when the popup ad is closed. showAd.AdClicked += AdClicked_Tap; // OPTIONAL. This is triggered when an ad is clicked by end user. showAd.ShowAdFailed += ShowAdFailed_Event; // OPTIONAL. This is triggered when no ad is available or an issue occurs (slow network connection...) showAd.ShowAdSuccess += ShowAdSucess_Event; // OPTIONAL. This is triggered when an ad is displayed to end user. showAd.MinDelayBtwAdsNotReached += MinDelayBtwAdsNotReached_Event; // OPTIONAL. This is triggered when you try to call more than 1 ad in a very short period of time (less than 3 sec). showAd.SDKNotInitialized += SDKNotInitialized_Event; // OPTIONAL. This is triggered when youn try to load an ad without initilizing the SDK. showAd.VideoRewardGranted += ShowAdVideoRewardGranted_Event; // REQUIRED FOR REWARDED VIDEOS If you want to notify the end user that a video view has been completed. if (0 == placementID.Length) { showAd.ShowAd(); } else { showAd.ShowAd(placementID); } }); }
/// <summary> /// <para> check ad available</para> /// </summary> /// <param name="adType">adType, 0(WALLAD), 1(FULLSCREENPOPUPAD), 2(REWARDEDVIDEOAD)</param> /// <param name="uiOrientation">invalid on UWP platform</param> public static void IsAvailable(int adType, int uiOrientation) { RunInUWPUIThread(() => { AdManager.AdKind adKind = (AdManager.AdKind)adType; Task <AdDealsPopupAd> task = AdManager.GetPopupAd(AdDealsWrapperUWP.rootPanel, adKind); task.Wait(); AdDealsPopupAd cachePopupAd = task.Result; if (AdManager.AdKind.REWARDEDVIDEOAD != adKind) { RunInUnityMainThread(() => { AdDealsWrapperUWP.AdAvailableEvent.Invoke(adType, cachePopupAd.IsCachedAdAvailable()); }); } else { Task <bool> taskAvailable = cachePopupAd.IsVideoAvailable(); taskAvailable.ContinueWith((t) => { RunInUnityMainThread(() => { AdDealsWrapperUWP.AdAvailableEvent.Invoke(adType, t.Result); }); }); } }); }
/// <summary> /// <para> cache ad</para> /// </summary> /// <param name="adType">adType, 0(WALLAD), 1(FULLSCREENPOPUPAD), 2(REWARDEDVIDEOAD)</param> /// <param name="placementID">in most cases just leave it ""</param> /// <param name="uiOrientation">invalid on UWP platform</param> public static void CacheAd(int adType, string placementID, int uiOrientation) { RunInUWPUIThread(() => { AdManager.AdKind adKind = (AdManager.AdKind)adType; Task <AdDealsPopupAd> cachePopupAdTask = AdManager.GetPopupAd(AdDealsWrapperUWP.rootPanel, adKind); cachePopupAdTask.Wait(); AdDealsPopupAd cachePopupAd = cachePopupAdTask.Result; cachePopupAd.CacheAdSuccess += CacheAdSuccess_Event; // OPTIONAL. This is triggered when an ad is cached successfully. cachePopupAd.CacheAdFailed += CacheAdFailed_Event; // OPTIONAL. This is triggered when an ad could not be cached. cachePopupAd.MinDelayBtwAdsNotReached += MinDelayBtwAdsNotReached_Event; // OPTIONAL. This is triggered when you try to call more than 1 ad in a very short period of time (less than 3 sec). cachePopupAd.SDKNotInitialized += SDKNotInitialized_Event; // OPTIONAL. This is triggered when youn try to load an ad without initilizing the SDK. if (0 == placementID.Length) { cachePopupAd.CacheAd(); } else { cachePopupAd.CacheAd(placementID); } }); }
/// <summary> /// /// </summary> /// <param name="adKind"></param> public async void ShowPopupAd(AdManager.AdKind adKind) { (await AdManager.GetPopupAd(this.LayoutRoot, adKind)).ShowAd(); }