Exemple #1
0
 private void InitAds()
 {
     // string gameId = Application.platform == RuntimePlatform.Android ? androidAppKey : iosAppKey;
     //Advertisement.Initialize(gameId, false);
     MobileAds.Initialize(Application.platform == RuntimePlatform.Android? DataParam.APP_ID:DataUtils.APP_ID);
     InitInterstitial();
     InitRewarded();
     InitBanner();
     UnityAds.SetGDPRConsentMetaData(true);
 }
    void Start()
    {
        Debug.Log("AdManager Started");
        List <string> deviceIds = new List <string>();

        deviceIds.Add("19EB01B237AD9FBA44A428C0A30235E7");

        /* RequestConfiguration requestConfiguration = new RequestConfiguration
         *   .Builder()
         *   .SetTestDeviceIds(deviceIds)
         *   .build();
         * MobileAds.SetRequestConfiguration(requestConfiguration);*/
        Debug.Log("Test devices are set");
        MobileAds.Initialize(HandleInitCompleteAction);
        UnityAds.SetGDPRConsentMetaData(true);
        loginClient = GameObject.Find("LoginClient").GetComponent <LoginClient>();
    }
        /// <summary>
        /// Initialize.
        /// </summary>
        public void Initialize(Action onCompleteCallback = null)
        {
#if DEBUG_MY_ADMOB
            Debug.Log("[" + typeof(MyAdMobManager).Name + "] Initialize()");
#endif

            if (mTestEnable && mTestDeviceId.Length > 0)
            {
                if (mTestUseGoogleAdsId)
                {
                    mAndroidDefaultBannerId         = "ca-app-pub-3940256099942544/6300978111";
                    mAndroidDefaultInterstitialAdId = "ca-app-pub-3940256099942544/1033173712";
                    mAndroidDefaultRewardedAdId     = "ca-app-pub-3940256099942544/5224354917";

                    mIosDefaultBannerId         = "ca-app-pub-3940256099942544/2934735716";
                    mIosDefaultInterstitialAdId = "ca-app-pub-3940256099942544/4411468910";
                    mIosDefaultRewardedAdId     = "ca-app-pub-3940256099942544/1712485313";

#if UNITY_ANDROID
                    PlayerPrefs.SetString("MyAdMobManager_BannerId", mAndroidDefaultBannerId);
                    PlayerPrefs.SetString("MyAdMobManager_InterstitialAdId", mAndroidDefaultInterstitialAdId);
                    PlayerPrefs.SetString("MyAdMobManager_RewardedAdId", mAndroidDefaultRewardedAdId);
#elif UNITY_IOS
                    PlayerPrefs.SetString("MyAdMobManager_BannerId", mIosDefaultBannerId);
                    PlayerPrefs.SetString("MyAdMobManager_InterstitialAdId", mIosDefaultInterstitialAdId);
                    PlayerPrefs.SetString("MyAdMobManager_RewardedAdId", mIosDefaultRewardedAdId);
#endif
                }

                List <string> deviceIds = new List <string>();
                deviceIds.AddRange(mTestDeviceId.Split(';'));
                RequestConfiguration requestConfiguration = new RequestConfiguration.Builder().SetTestDeviceIds(deviceIds).build();
                MobileAds.SetRequestConfiguration(requestConfiguration);
            }

            MobileAds.Initialize(initStatus =>
            {
#if DEBUG_MY_ADMOB
                Debug.Log("[" + typeof(MyAdMobManager).Name + "] Initialize(): completed");
#endif

                mIsInitialized = true;

                if (onCompleteCallback != null)
                {
                    onCompleteCallback();
                }
            });

#if USE_MY_ADMOB_APPLOVIN
            AppLovin.Initialize();
            AppLovin.SetHasUserConsent(true);
#endif

#if USE_MY_ADMOB_MOPUB
            MoPub.InitializeSdk("8c09b6f2cb324838acf2fdad6899f5a8");
#endif

#if USE_MY_ADMOB_UNITY_ADS
            UnityAds.SetGDPRConsentMetaData(true);
#endif

#if USE_MY_ADMOB_VUNGLE
            Vungle.UpdateConsentStatus(VungleConsent.ACCEPTED);
#endif
        }