IEnumerator CoRequestInterstitialNoShow(AdPlacement.Type placementType, InterstitialDelegate onAdLoaded = null, bool showLoading = true) { isLoadingInterstitial = true; bool isSuccess = false; WaitForSecondsRealtime checkInterval = new WaitForSecondsRealtime(0.05f); var adPriority = GetAdsNetworkPriority(placementType); for (int i = 0; i < adPriority.Count; i++) { bool checkAdNetworkDone = false; IAdsNetworkHelper adsHelper = GetAdsNetworkHelper(adPriority[i]); if (adsHelper == null) { continue; } adsHelper.RequestInterstitialNoShow(placementType, (success) => { checkAdNetworkDone = true; isSuccess = success; }, showLoading); while (!checkAdNetworkDone) { yield return(checkInterval); } if (isSuccess) { //CurrentAdNetwork = AdNetworkSetting.AdNetworks[i]; currentAdsHelper = adsHelper; break; } } //.Log($"AdsManager: CoRequestInterstitialNoShow done {isSuccess}"); onAdLoaded?.Invoke(isSuccess); isLoadingInterstitial = false; if (showLoading) { Manager.LoadingAnimation(false); } }
/// <summary> /// Check if user has purchased remove ads and remote config. Return true if this ads is hidden /// </summary> public bool DoNotShowAds(AdPlacement.Type placementType) { bool isNoAds = false; if (noAds != null) { var noAdsInvokeList = noAds.GetInvocationList(); for (int i = 0; i < noAdsInvokeList.Length; i++) { isNoAds = isNoAds || (bool)noAdsInvokeList[i].DynamicInvoke(); //.Log($"AdsManager: {noAdsInvokeList[i].Method.Name}"); } } //.Log($"AdsManager: do not show ads {placementType}: {isNoAds}"); if (isNoAds) { return(true); } if (IsAdsHiddenRemoteConfig(placementType)) { return(true); } return(false); }
public static void ShowError(string msg, AdPlacement.Type placementType) { onAdLoadFailed?.Invoke(msg, placementType); }
IEnumerator CoReward(BoolDelegate onFinish, AdPlacement.Type placementType) { RewardResult rewardResult = new RewardResult(); string errorMsg = string.Empty; if (IsAdsHiddenRemoteConfig(placementType)) { rewardResult.type = RewardResult.Type.LoadFailed; rewardResult.message = "Disabled"; } else if (HasNoInternet()) { rewardResult.type = RewardResult.Type.LoadFailed; rewardResult.message = "No Internet connection"; } else { WaitForSecondsRealtime checkInterval = new WaitForSecondsRealtime(0.3f); List <CustomMediation.AD_NETWORK> adPriority = GetAdsNetworkPriority(placementType); for (int i = 0; i < adPriority.Count; i++) { bool checkAdNetworkDone = false; IAdsNetworkHelper adsHelper = GetAdsNetworkHelper(adPriority[i]); if (adsHelper == null) { continue; } adsHelper.Reward(placementType, (result) => { checkAdNetworkDone = true; rewardResult = result; }); while (!checkAdNetworkDone) { yield return(checkInterval); } if (rewardResult.type == RewardResult.Type.Finished) { currentAdsHelper = adsHelper; break; } if (rewardResult.type == RewardResult.Type.Canceled) { break; } //if a reward ads was shown and user skipped it, stop looking for more ads } } /*for (int i = 0; i < adsNetworkHelpers.Count; i++) * { * bool checkAdNetworkDone = false; * adsNetworkHelpers[i].Reward(placementType, (result) => * { * checkAdNetworkDone = true; rewardResult = result; * }); * while (!checkAdNetworkDone) * { * yield return checkInterval; * } * if (rewardResult.type == RewardResult.Type.Finished) * { * currentAdsHelper = adsNetworkHelpers[i]; * break; * } * if (rewardResult.type == RewardResult.Type.Canceled) { break; } //if a reward ads was shown and user skipped it, stop looking for more ads * }*/ onFinish(rewardResult.type == RewardResult.Type.Finished); Manager.LoadingAnimation(false); if (rewardResult.type == RewardResult.Type.LoadFailed) { ShowError(rewardResult.message, placementType); } }
public static void Reward(BoolDelegate onFinish, AdPlacement.Type placementType) { Manager.LoadingAnimation(true); instance.StartCoroutine(instance.CoReward(onFinish, placementType)); }
public void ShowInterstitialRewarded(AdPlacement.Type placementType, RewardDelegate onAdClosed) { onAdClosed?.Invoke(new RewardResult(RewardResult.Type.LoadFailed, "Not supported by Unity Ads")); }
public void RequestInterstitialRewardedNoShow(AdPlacement.Type placementType, RewardDelegate onFinish = null) { onFinish?.Invoke(new RewardResult(RewardResult.Type.LoadFailed, "Not supported by Unity Ads")); }
public void Reward(AdPlacement.Type placementType, RewardDelegate onFinish) { Reward(onFinish, CustomMediation.GetUnityPlacementId(placementType)); }
public void RequestInterstitialNoShow(AdPlacement.Type placementType, AdsManager.InterstitialDelegate onAdLoaded = null, bool showLoading = true) { RequestInterstitialNoShow(CustomMediation.GetUnityPlacementId(placementType), onAdLoaded, showLoading); }
public void ShowInterstitial(AdPlacement.Type placementType, AdsManager.InterstitialDelegate onAdClosed) { onInterstitialClosed = onAdClosed; ShowInterstitial(CustomMediation.GetUnityPlacementId(placementType), onAdClosed); }
public void ShowBanner(AdPlacement.Type placementType, AdsManager.InterstitialDelegate onAdLoaded = null) { ShowBanner(placementType, Omnilatent.AdsMediation.BannerTransform.defaultValue, onAdLoaded); }