/// <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; } }
protected override void InternalInit() { #if EM_APPLOVIN mAdSettings = EM_Settings.Advertising.AppLovin; mCustomRewardedVideoAds = new List <AdPlacement>(); mCustomInterstitialAds = new List <AdPlacement>(); mCustomBanners = new Dictionary <AdPlacement, KeyValuePair <BannerAdPosition, BannerAdSize> >(); // Set GDPR consent if any. var consent = GetApplicableDataPrivacyConsent(); ApplyDataPrivacyConsent(consent); AppLovin.SetSdkKey(mAdSettings.SDKKey); AppLovin.InitializeSdk(); // Test Mode if (mAdSettings.EnableTestMode) { AppLovin.SetTestAdsEnabled("true"); } else { AppLovin.SetTestAdsEnabled("false"); } // Age-Restricted if (mAdSettings.AgeRestrictMode) { AppLovin.SetIsAgeRestrictedUser("true"); } else { AppLovin.SetIsAgeRestrictedUser("false"); } AppLovin.LoadRewardedInterstitial(); // Setup Events Listener GameObject listener = new GameObject(); listener.name = "EM_AppLovinAdsListenerObject"; UnityEngine.Object.Instantiate(listener, Vector3.zero, Quaternion.identity); listener.AddComponent <EM_AppLovinAdsListener>(); listener.GetComponent <EM_AppLovinAdsListener>().setAdClient(this); AppLovin.SetUnityAdListener("EM_AppLovinAdsListenerObject"); // Done Initialization. mIsInitialized = true; Debug.Log("AppLovin client has been initialized."); #endif }