/// <summary> /// Initializing AppLovin /// </summary> /// <param name="consent">user consent -> if true show personalized ads</param> /// <param name="platformSettings">contains all required settings for this publisher</param> public void InitializeAds(UserConsent consent, UserConsent ccpaConsent, List <PlatformSettings> platformSettings) { debug = Advertisements.Instance.debug; if (initialized == false) { if (debug) { AppLovin.SetVerboseLoggingOn("true"); } //get settings #if UNITY_ANDROID PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Android); #endif #if UNITY_IOS PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.iOS); #endif //preparing AppLovin SDK for initialization Debug.Log("APPID: " + settings.appId.id.ToString()); AppLovin.SetSdkKey(settings.appId.id.ToString()); if (consent == UserConsent.Accept || consent == UserConsent.Unset) { AppLovin.SetHasUserConsent("true"); } else { AppLovin.SetHasUserConsent("false"); } if (settings.directedForChildren == true) { AppLovin.SetIsAgeRestrictedUser("true"); } else { AppLovin.SetIsAgeRestrictedUser("false"); } AppLovin.InitializeSdk(); AppLovin.SetUnityAdListener(gameObject.name); if (debug) { Debug.Log(this + " " + "Start Initialization"); ScreenWriter.Write(this + " " + "Start Initialization"); Debug.Log(this + " SDK key: " + settings.appId.id); ScreenWriter.Write(this + " SDK key: " + settings.appId.id); } //start loading ads PreloadInterstitial(); PreloadRewardedVideo(); initialized = true; } }
/// <summary> /// Initializing Chartboost /// </summary> /// <param name="consent">user consent -> if true show personalized ads</param> /// <param name="platformSettings">contains all required settings for this publisher</param> public void InitializeAds(UserConsent consent, UserConsent ccpaConsent, List <PlatformSettings> platformSettings) { debug = Advertisements.Instance.debug; if (debug) { Debug.Log(this + " " + "Start Initialization"); ScreenWriter.Write(this + " " + "Start Initialization"); } //get settings #if UNITY_ANDROID PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Android); #endif #if UNITY_IOS PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.iOS); #endif //apply settings chartboostAppId = settings.appId.id; chartboostAppSignature = settings.idInterstitial.id; CBSettings.setAppId(chartboostAppId, chartboostAppSignature); gameObject.AddComponent <Chartboost>(); //preparing Chartboost SDK for initialization if (consent == UserConsent.Deny) { Chartboost.addDataUseConsent(CBGDPRDataUseConsent.NoBehavioral); } else { Chartboost.addDataUseConsent(CBGDPRDataUseConsent.Behavioral); } if (ccpaConsent == UserConsent.Deny) { Chartboost.addDataUseConsent(CBCCPADataUseConsent.OptOutSale); } else { Chartboost.addDataUseConsent(CBCCPADataUseConsent.OptInSale); } //add listeners Chartboost.didFailToLoadInterstitial += FailInterstitial; Chartboost.didCacheInterstitial += InterstitialLoaded; Chartboost.didDismissInterstitial += ReloadInterstitial; Chartboost.didCompleteRewardedVideo += RewardedVideoCompleted; Chartboost.didFailToLoadRewardedVideo += FailRewarded; Chartboost.didCacheRewardedVideo += RewardedLoaded; Chartboost.didDismissRewardedVideo += ReloadRewarded; Chartboost.didInitialize += InitializationSuccess; //start loading ads LoadInterstitial(); LoadRewardedVideo(); }
/// <summary> /// Initializing MoPub /// </summary> /// <param name="consent">user consent -> if true show personalized ads</param> /// <param name="platformSettings">contains all required settings for this publisher</param> public void InitializeAds(UserConsent consent, UserConsent ccpaConsent, List <PlatformSettings> platformSettings) { debug = Advertisements.Instance.debug; if (initialized == false) { initialized = true; //get settings #if UNITY_ANDROID PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Android); #endif #if UNITY_IOS PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.iOS); #endif //apply settings bannerAdUnit = settings.idBanner.id; interstitialAdUnit = settings.idInterstitial.id; rewardedVideoAdUnit = settings.idRewarded.id; this.consent = consent; this.ccpaConsent = ccpaConsent; //verify settings if (debug) { Debug.Log(this + " Initialize"); ScreenWriter.Write(this + " Initialize"); Debug.Log(this + " Banner ID: " + bannerAdUnit); ScreenWriter.Write(this + " Banner ID: " + bannerAdUnit); Debug.Log(this + " Interstitial ID: " + interstitialAdUnit); ScreenWriter.Write(this + " Interstitial ID: " + interstitialAdUnit); Debug.Log(this + " Rewarded ID: " + rewardedVideoAdUnit); ScreenWriter.Write(this + " Rewarded ID: " + rewardedVideoAdUnit); } MoPubManager.OnSdkInitializedEvent += SDKInitialized; string defaultID = null; if (string.IsNullOrEmpty(defaultID)) { defaultID = bannerAdUnit; } if (string.IsNullOrEmpty(defaultID)) { defaultID = interstitialAdUnit; } if (string.IsNullOrEmpty(defaultID)) { defaultID = rewardedVideoAdUnit; } if (!string.IsNullOrEmpty(defaultID)) { MoPub.InitializeSdk(defaultID); } } }
/// <summary> /// Initializing Audience Network /// </summary> /// <param name="consent"></param> /// <param name="platformSettings">contains all required settings for this publisher</param> public void InitializeAds(UserConsent consent, UserConsent ccpaConsent, List <PlatformSettings> platformSettings) { debug = Advertisements.Instance.debug; if (initialized == false) { if (debug) { Debug.Log(this + " " + "Start Initialization"); ScreenWriter.Write(this + " " + "Start Initialization"); } //get settings #if UNITY_ANDROID PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Android); #endif #if UNITY_IOS PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.iOS); #endif //apply settings interstitialId = settings.idInterstitial.id; bannerId = settings.idBanner.id; rewardedVideoId = settings.idRewarded.id; directedForChildren = settings.directedForChildren; //verify settings if (debug) { Debug.Log(this + " Banner ID: " + bannerId); ScreenWriter.Write(this + " Banner ID: " + bannerId); Debug.Log(this + " Interstitial ID: " + interstitialId); ScreenWriter.Write(this + " Interstitial ID: " + interstitialId); Debug.Log(this + " Rewarded Video ID: " + rewardedVideoId); ScreenWriter.Write(this + " Rewarded Video ID: " + rewardedVideoId); Debug.Log(this + " Directed for children: " + directedForChildren); ScreenWriter.Write(this + " Directed for children: " + directedForChildren); } AudienceNetwork.AdSettings.SetIsChildDirected(directedForChildren); if (!string.IsNullOrEmpty(interstitialId)) { LoadInterstitial(); } if (!string.IsNullOrEmpty(rewardedVideoId)) { LoadRewardedVideo(); } initialized = true; } }
/// <summary> /// Initializing Heyzap /// </summary> /// <param name="consent">user consent -> if true show personalized ads</param> /// <param name="platformSettings">contains all required settings for this publisher</param> public void InitializeAds(GDPRConsent consent, List <PlatformSettings> platformSettings) { debug = Advertisements.Instance.debug; //get settings #if UNITY_ANDROID PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Android); #endif #if UNITY_IOS PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.iOS); #endif //apply settings publisherId = settings.appId.id; //verify settings if (debug) { Debug.Log(this + " Initialization Started"); ScreenWriter.Write(this + " Initialization Started"); Debug.Log(this + " Publisher ID: " + publisherId); ScreenWriter.Write(this + " Publisher ID: " + publisherId); } AdListeners(); //preparing Heyzap SDK for initialization if (consent == GDPRConsent.Accept || consent == GDPRConsent.Unset) { HeyzapAds.SetGdprConsent(true); } else { HeyzapAds.SetGdprConsent(false); } if (settings.directedForChildren == true) { HeyzapAds.Start(publisherId, HeyzapAds.FLAG_CHILD_DIRECTED_ADS); } else { HeyzapAds.Start(publisherId, HeyzapAds.FLAG_NO_OPTIONS); } //start loading ads HZInterstitialAd.Fetch(); HZIncentivizedAd.Fetch(); //HeyzapAds.ShowMediationTestSuite(); }
/// <summary> /// Initializing Vungle /// </summary> /// <param name="consent">user consent -> if true show personalized ads</param> /// <param name="platformSettings">contains all required settings for this publisher</param> public void InitializeAds(UserConsent consent, UserConsent ccpaConsent, List <PlatformSettings> platformSettings) { this.consent = consent; debug = Advertisements.Instance.debug; //get settings #if UNITY_ANDROID PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Android); #elif UNITY_IOS PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.iOS); #else PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Windows); #endif //apply settings appID = settings.appId.id; rewardedPlacementId = settings.idRewarded.id; interstitialPlacementID = settings.idInterstitial.id; //verify settings if (debug) { Debug.Log(this + " Initialization Started"); ScreenWriter.Write(this + " Initialization Started"); Debug.Log(this + " App ID: " + appID); ScreenWriter.Write(this + " App ID: " + appID); Debug.Log(this + " Interstitial Placement ID: " + interstitialPlacementID); ScreenWriter.Write(this + " Interstitial Placement ID: " + interstitialPlacementID); Debug.Log(this + " Rewarded Video Placement ID: " + rewardedPlacementId); ScreenWriter.Write(this + " Rewarded Video Placement ID: " + rewardedPlacementId); } //preparing Vungle SDK for initialization Dictionary <string, bool> placements = new Dictionary <string, bool> { { rewardedPlacementId, false }, { interstitialPlacementID, false } }; string[] array = new string[placements.Keys.Count]; placements.Keys.CopyTo(array, 0); Vungle.init(appID); Vungle.onInitializeEvent += InitCOmplete; Vungle.onLogEvent += VungleLog; Vungle.onAdFinishedEvent += Vungle_onAdFinishedEvent; }
/// <summary> /// Initializing Unity Ads /// </summary> /// <param name="consent">user consent -> if true show personalized ads</param> /// <param name="platformSettings">contains all required settings for this publisher</param> public void InitializeAds(UserConsent consent, UserConsent ccpaConsent, List <PlatformSettings> platformSettings) { debug = Advertisements.Instance.debug; //get settings #if UNITY_ANDROID PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Android); #endif #if UNITY_IOS PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.iOS); #endif //apply settings unityAdsId = settings.appId.id; bannerPlacement = settings.idBanner.id; videoAdPlacement = settings.idInterstitial.id; rewardedVideoAdPlacement = settings.idRewarded.id; //verify settings if (debug) { Debug.Log(this + " Initialization Started"); ScreenWriter.Write(this + " Initialization Started"); Debug.Log(this + " App ID: " + unityAdsId); ScreenWriter.Write(this + " App ID: " + unityAdsId); Debug.Log(this + " Banner placement ID: " + bannerPlacement); ScreenWriter.Write(this + " Banner Placement ID: " + bannerPlacement); Debug.Log(this + " Interstitial Placement ID: " + videoAdPlacement); ScreenWriter.Write(this + " Interstitial Placement ID: " + videoAdPlacement); Debug.Log(this + " Rewarded Video Placement ID: " + rewardedVideoAdPlacement); ScreenWriter.Write(this + " Rewarded Video Placement ID: " + rewardedVideoAdPlacement); } //preparing Unity Ads SDK for initialization if (consent != UserConsent.Unset) { MetaData gdprMetaData = new MetaData("gdpr"); if (consent == UserConsent.Accept) { gdprMetaData.Set("consent", "true"); } else { gdprMetaData.Set("consent", "false"); } Advertisement.SetMetaData(gdprMetaData); } if (ccpaConsent != UserConsent.Unset) { MetaData privacyMetaData = new MetaData("privacy"); if (consent == UserConsent.Accept) { privacyMetaData.Set("consent", "true"); } else { privacyMetaData.Set("consent", "false"); } Advertisement.SetMetaData(privacyMetaData); } Advertisement.AddListener(this); Advertisement.Initialize(unityAdsId, false); }
/// <summary> /// Initializing IronSource /// </summary> /// <param name="consent">user consent -> if true show personalized ads</param> /// <param name="platformSettings">contains all required settings for this publisher</param> public void InitializeAds(UserConsent consent, UserConsent ccpaConsent, List <PlatformSettings> platformSettings) { debug = Advertisements.Instance.debug; if (initialized == false) { initialized = true; #if UNITY_ANDROID PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Android); #endif #if UNITY_IOS PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.iOS); #endif //apply settings appKey = settings.appId.id; bannerAdUnit = settings.idBanner.id; interstitialAdUnit = settings.idInterstitial.id; rewardedVideoAdUnit = settings.idRewarded.id; //verify settings if (debug) { Debug.Log(this + " Initialize"); ScreenWriter.Write(this + " Initialize"); Debug.Log(this + " App Key: " + appKey); ScreenWriter.Write(this + " App Key: " + appKey); Debug.Log(this + " Banner ID: " + bannerAdUnit); ScreenWriter.Write(this + " Banner ID: " + bannerAdUnit); Debug.Log(this + " Interstitial ID: " + interstitialAdUnit); ScreenWriter.Write(this + " Interstitial ID: " + interstitialAdUnit); Debug.Log(this + " Rewarded ID: " + rewardedVideoAdUnit); ScreenWriter.Write(this + " Rewarded ID: " + rewardedVideoAdUnit); } UpdateConsent(consent, ccpaConsent); if (!string.IsNullOrEmpty(bannerAdUnit)) { IronSourceEvents.onBannerAdLoadedEvent += BannerAdLoadedEvent; IronSourceEvents.onBannerAdLoadFailedEvent += BannerAdLoadFailedEvent; IronSourceEvents.onBannerAdClickedEvent += BannerAdClickedEvent; IronSourceEvents.onBannerAdScreenPresentedEvent += BannerAdScreenPresentedEvent; IronSourceEvents.onBannerAdScreenDismissedEvent += BannerAdScreenDismissedEvent; IronSourceEvents.onBannerAdLeftApplicationEvent += BannerAdLeftApplicationEvent; IronSource.Agent.init(appKey, IronSourceAdUnits.BANNER); } if (!string.IsNullOrEmpty(interstitialAdUnit)) { IronSourceEvents.onInterstitialAdReadyEvent += InterstitialAdReadyEvent; IronSourceEvents.onInterstitialAdLoadFailedEvent += InterstitialAdLoadFailedEvent; IronSourceEvents.onInterstitialAdShowSucceededEvent += InterstitialAdShowSucceededEvent; IronSourceEvents.onInterstitialAdShowFailedEvent += InterstitialAdShowFailedEvent; IronSourceEvents.onInterstitialAdClickedEvent += InterstitialAdClickedEvent; IronSourceEvents.onInterstitialAdOpenedEvent += InterstitialAdOpenedEvent; IronSourceEvents.onInterstitialAdClosedEvent += InterstitialAdClosedEvent; IronSource.Agent.init(appKey, IronSourceAdUnits.INTERSTITIAL); LoadInterstitial(); } if (!string.IsNullOrEmpty(rewardedVideoAdUnit)) { IronSourceEvents.onRewardedVideoAdOpenedEvent += RewardedVideoAdOpenedEvent; IronSourceEvents.onRewardedVideoAdClosedEvent += RewardedVideoAdClosedEvent; IronSourceEvents.onRewardedVideoAvailabilityChangedEvent += RewardedVideoAvailabilityChangedEvent; IronSourceEvents.onRewardedVideoAdStartedEvent += RewardedVideoAdStartedEvent; IronSourceEvents.onRewardedVideoAdEndedEvent += RewardedVideoAdEndedEvent; IronSourceEvents.onRewardedVideoAdRewardedEvent += RewardedVideoAdRewardedEvent; IronSourceEvents.onRewardedVideoAdShowFailedEvent += RewardedVideoAdShowFailedEvent; IronSource.Agent.init(appKey, IronSourceAdUnits.REWARDED_VIDEO); } //IronSource.Agent.validateIntegration(); } }
/// <summary> /// Initializing AdColony /// </summary> /// <param name="consent">user consent -> if true show personalized ads</param> /// <param name="platformSettings">contains all required settings for this publisher</param> public void InitializeAds(UserConsent consent, UserConsent ccpaConsent, List <PlatformSettings> platformSettings) { debug = Advertisements.Instance.debug; //get settings #if UNITY_ANDROID PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Android); #endif #if UNITY_IOS PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.iOS); #endif //apply settings appId = settings.appId.id; bannerZoneId = settings.idBanner.id; interstitialZoneId = settings.idInterstitial.id; rewardedZoneId = settings.idRewarded.id; //add listeners Ads.OnConfigurationCompleted += OnConfigurationCompleted; Ads.OnRequestInterstitial += OnRequestInterstitial; Ads.OnRequestInterstitialFailedWithZone += OnRequestInterstitialFailed; Ads.OnClosed += OnClosed; Ads.OnRewardGranted += OnRewardGranted; Ads.OnAdViewLoaded += BannerLoaded; Ads.OnAdViewFailedToLoad += BannerLoadFailed; //preparing AdColony SDK for initialization AppOptions appOptions = new AppOptions(); appOptions.AdOrientation = AdOrientationType.AdColonyOrientationAll; appOptions.GdprRequired = true; if (consent == UserConsent.Unset || consent == UserConsent.Accept) { appOptions.GdprConsentString = "1"; } else { appOptions.GdprConsentString = "0"; } List <string> zoneIDs = new List <string>(); if (!string.IsNullOrEmpty(bannerZoneId)) { zoneIDs.Add(bannerZoneId); } if (!string.IsNullOrEmpty(interstitialZoneId)) { zoneIDs.Add(interstitialZoneId); } if (!string.IsNullOrEmpty(rewardedZoneId)) { zoneIDs.Add(rewardedZoneId); } if (zoneIDs.Count == 0) { Debug.LogError("Please add your IDs in SettingsWindow"); return; } //Apply configuration Ads.Configure(appId, appOptions, zoneIDs.ToArray()); //verify settings if (debug) { Debug.Log(this + " Initialize"); ScreenWriter.Write(this + " Initialize"); Debug.Log(this + " App ID: " + appId); ScreenWriter.Write(this + " App ID: " + appId); Debug.Log(this + " Banner Zone ID: " + bannerZoneId); ScreenWriter.Write(this + " Banner Zone ID: " + bannerZoneId); Debug.Log(this + " Interstitial Zone ID: " + interstitialZoneId); ScreenWriter.Write(this + " Interstitial Zone ID: " + interstitialZoneId); Debug.Log(this + " Rewarded Zone ID: " + rewardedZoneId); ScreenWriter.Write(this + " Rewarded Zone ID: " + rewardedZoneId); } }
/// <summary> /// Initializing Admob /// </summary> /// <param name="consent">user consent -> if true show personalized ads</param> /// <param name="platformSettings">contains all required settings for this publisher</param> public void InitializeAds(UserConsent consent, UserConsent ccpaConsent, List <PlatformSettings> platformSettings) { debug = Advertisements.Instance.debug; if (initialized == false) { if (debug) { Debug.Log("Admob Start Initialization"); ScreenWriter.Write("Admob Start Initialization"); } //get settings #if UNITY_ANDROID PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Android); #endif #if UNITY_IOS PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.iOS); #endif //apply settings interstitialId = settings.idInterstitial.id; bannerId = settings.idBanner.id; rewardedVideoId = settings.idRewarded.id; TagForChildDirectedTreatment tagFororChildren; if (settings.directedForChildren == true) { designedForFamilies = "true"; tagFororChildren = TagForChildDirectedTreatment.True; } else { designedForFamilies = "false"; tagFororChildren = TagForChildDirectedTreatment.Unspecified; } directedForChildren = settings.directedForChildren; RequestConfiguration requestConfiguration = new RequestConfiguration.Builder().SetTagForChildDirectedTreatment(tagFororChildren).build(); MobileAds.SetRequestConfiguration(requestConfiguration); MobileAds.SetiOSAppPauseOnBackground(true); //verify settings if (debug) { Debug.Log("Admob Banner ID: " + bannerId); ScreenWriter.Write("Admob Banner ID: " + bannerId); Debug.Log("Admob Interstitial ID: " + interstitialId); ScreenWriter.Write("Admob Interstitial ID: " + interstitialId); Debug.Log("Admob Rewarded Video ID: " + rewardedVideoId); ScreenWriter.Write("Admob Rewarded Video ID: " + rewardedVideoId); Debug.Log("Admob Directed for children: " + directedForChildren); ScreenWriter.Write("Admob Directed for children: " + directedForChildren); } //preparing Admob SDK for initialization if (consent == UserConsent.Unset || consent == UserConsent.Accept) { this.consent = "0"; } else { this.consent = "1"; } if (ccpaConsent == UserConsent.Unset || ccpaConsent == UserConsent.Accept) { this.ccpaConsent = "0"; } else { this.ccpaConsent = "1"; } MobileAds.Initialize(InitComplete); initialized = true; } }