public void RequestInterstitialNoShow(AdPlacementType placementType, InterstitialDelegate onAdLoaded = null, bool showLoading = true) { //if (DoNotShowAds(placementType) || !HasEnoughTimeBetweenInterstitial()) //skip checking interstitial time so we can use this function for preloading interstitial ads if (DoNotShowAds(placementType)) { onAdLoaded?.Invoke(false); return; } if (isLoadingInterstitial) { Debug.LogWarning("Previous interstitial request is still loading"); onAdLoaded?.Invoke(false); //added this so game can continue even with interstitial not finished loading return; } if (showLoading) { Manager.LoadingAnimation(true); } StartCoroutine(CoRequestInterstitialNoShow(placementType, onAdLoaded, showLoading)); timeLastShowInterstitial = time; /*switch (CurrentAdNetwork) * { * case CustomMediation.AD_NETWORK.Unity: * UnityAdsManager.instance.RequestInterstitialNoShow(CustomMediation.GetUnityPlacementId(placementType), onAdLoaded, showLoading); * break; * case CustomMediation.AD_NETWORK.FAN: * FacebookAudienceNetworkHelper.instance.RequestInterstitialNoShow(CustomMediation.GetFANPlacementId(placementType), onAdLoaded, showLoading); * break; * }*/ }
/// <param name="onAdClosed">Warning: not completely functional yet, only Admob will call onAdClosed when the interstitial is closed</param> public void ShowInterstitial(AdPlacementType placeType, InterstitialDelegate onAdClosed = null) { if (currentAdsHelper == null) { Debug.LogError("currentAdsHelper is null due to all ads failed to load"); return; } currentAdsHelper.ShowInterstitial(placeType, onAdClosed); /*switch (CurrentAdNetwork) * { * case CustomMediation.AD_NETWORK.Unity: * UnityAdsManager.ShowInterstitial(CustomMediation.GetUnityPlacementId(placeType)); * break; * case CustomMediation.AD_NETWORK.FAN: * _FANHelper.ShowInterstitial(CustomMediation.GetFANPlacementId(placeType)); * break; * }*/ }
public void loadInterstitialForZoneId(string zoneIdiOS, string zoneIdAndroid, bool refresh) { if (refresh) { if (state != InterstitialState.New && state != InterstitialState.Loaded) { return; } } else if (state != InterstitialState.New) { return; } androidZoneId = zoneIdAndroid; iosZoneId = zoneIdiOS; isRefresh = refresh; state = InterstitialState.Loading; InterstitialDelegate interstitialDelegate = new InterstitialDelegate(this); if (Application.platform == RuntimePlatform.IPhonePlayer) { if (zoneIdiOS != null) { interstitial = new AMR.iOS.AMRInterstitial(); interstitial.loadInterstitialForZoneId(zoneIdiOS, interstitialDelegate); } } else if (Application.platform == RuntimePlatform.Android) { if (zoneIdAndroid != null) { if (interstitial != null) { interstitial.destroyInterstitial(); } interstitial = new AMR.Android.AMRInterstitial(); interstitial.loadInterstitialForZoneId(zoneIdAndroid, interstitialDelegate); } } }
IEnumerator CoRequestInterstitialNoShow(AdPlacementType 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); } }