private void CreateManager()
        {
            Logger.LogDebug("Creating SmartAds manager");

            try {
                if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    #if UNITY_IOS
                    manager = new Ads.iOS.SmartAdsManager();
                    #endif
                }
                else if (Application.platform == RuntimePlatform.Android)
                {
                    #if UNITY_ANDROID
                    manager = new Ads.Android.AdService(
                        this,
                        Settings.SDK_VERSION.Remove(0, Settings.SDK_VERSION.IndexOf(" v") + 2));
                    #endif
                }
                else
                {
                    #if UNITY_EDITOR
                    manager = new Ads.UnityPlayer.AdService();
                    #else
                    Logger.LogWarning("SmartAds is not currently supported on " + Application.platform);
                    #endif
                }
            } catch (Exception exception) {
                DidFailToRegisterForInterstitialAds(exception.Message);
                DidFailToRegisterForRewardedAds(exception.Message);
            }
        }
Exemple #2
0
        public void RegisterForAds()
        {
            Logger.LogInfo("Registering for ads");

            if (!DDNA.Instance.HasStarted)
            {
                Logger.LogError("The DeltaDNA SDK must be started before calling RegisterForAds.");
                return;
            }

            try
            {
                if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    #if UNITY_IOS
                    manager = new DeltaDNAAds.iOS.SmartAdsManager();
                    manager.RegisterForAds(SMARTADS_DECISION_POINT);
                    #endif
                }
                else if (Application.platform == RuntimePlatform.Android)
                {
                    #if UNITY_ANDROID
                    manager = new DeltaDNAAds.Android.AdService(
                        this,
                        Settings.SDK_VERSION.Remove(0, Settings.SDK_VERSION.IndexOf(" v") + 2));
                    manager.RegisterForAds(SMARTADS_DECISION_POINT);
                    #endif
                }
                else
                {
                    Logger.LogWarning("SmartAds is not currently supported on " + Application.platform);
                }
            }
            catch (Exception exception)
            {
                this.DidFailToRegisterForInterstitialAds(exception.Message);
                this.DidFailToRegisterForRewardedAds(exception.Message);
            }

            if (manager != null)
            {
                DDNA.Instance.OnNewSession -= manager.OnNewSession;
                DDNA.Instance.OnNewSession += manager.OnNewSession;
            }
        }