update: 添加广告启动配置, 添加 IAP 的购买广告的标志位
# Conflicts: # Runtime/GuruIAP/Runtime/Code/IAPModel.cs # Runtime/GuruIAP/Runtime/Code/IAPServiceBase.csdeeplink
							parent
							
								
									269010590d
								
							
						
					
					
						commit
						c4c711f6f8
					
				| 
						 | 
					@ -1,3 +0,0 @@
 | 
				
			||||||
fileFormatVersion: 2
 | 
					 | 
				
			||||||
guid: 811ed48c0c0a487486c74abd56463199
 | 
					 | 
				
			||||||
timeCreated: 1709268219
 | 
					 | 
				
			||||||
| 
						 | 
					@ -23,8 +23,6 @@ namespace Guru
 | 
				
			||||||
        protected bool IsNetworkEnabled => Application.internetReachability != NetworkReachability.NotReachable;
 | 
					        protected bool IsNetworkEnabled => Application.internetReachability != NetworkReachability.NotReachable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private bool _isServiceStarted;
 | 
					        private bool _isServiceStarted;
 | 
				
			||||||
        protected bool _isDebugMode;
 | 
					 | 
				
			||||||
        protected bool _isAutoLoadAds;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private Action _onSdkInitReady;
 | 
					        private Action _onSdkInitReady;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
| 
						 | 
					@ -37,6 +35,7 @@ namespace Guru
 | 
				
			||||||
        public static Action OnRewardFailed;
 | 
					        public static Action OnRewardFailed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private AdsModel _model;
 | 
					        private AdsModel _model;
 | 
				
			||||||
 | 
					        private AdsInitSpec _initSpec = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 启动广告服务
 | 
					        /// 启动广告服务
 | 
				
			||||||
| 
						 | 
					@ -44,13 +43,12 @@ namespace Guru
 | 
				
			||||||
        /// <param name="callback">广告初始化回调</param>
 | 
					        /// <param name="callback">广告初始化回调</param>
 | 
				
			||||||
        /// <param name="autoLoadAds">自动启动广告加载</param>
 | 
					        /// <param name="autoLoadAds">自动启动广告加载</param>
 | 
				
			||||||
        /// <param name="isDebugMode">debug模式</param>
 | 
					        /// <param name="isDebugMode">debug模式</param>
 | 
				
			||||||
        public virtual void StartService(Action callback = null, bool autoLoadAds = true, bool isDebugMode = false)
 | 
					        public virtual void StartService(Action callback = null, AdsInitSpec initSpec = null)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (IsInitialized) return; // 已经初始化后, 无需再次初始化
 | 
					            if (IsInitialized) return; // 已经初始化后, 无需再次初始化
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            _initSpec = initSpec;
 | 
				
			||||||
            _isServiceStarted = true;
 | 
					            _isServiceStarted = true;
 | 
				
			||||||
            _isAutoLoadAds = autoLoadAds;
 | 
					 | 
				
			||||||
            _isDebugMode = isDebugMode;
 | 
					 | 
				
			||||||
            _onSdkInitReady = callback;
 | 
					            _onSdkInitReady = callback;
 | 
				
			||||||
            _model = AdsModel.Create();
 | 
					            _model = AdsModel.Create();
 | 
				
			||||||
            this.Log("AD SDK Start Init");
 | 
					            this.Log("AD SDK Start Init");
 | 
				
			||||||
| 
						 | 
					@ -82,7 +80,8 @@ namespace Guru
 | 
				
			||||||
            MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
 | 
					            MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //-------------- SDK 初始化 -------------------
 | 
					            //-------------- SDK 初始化 -------------------
 | 
				
			||||||
            MaxSdk.SetVerboseLogging(_isDebugMode);
 | 
					            if (_initSpec == null) _initSpec = AdsInitSpec.BuildDefault();
 | 
				
			||||||
 | 
					            MaxSdk.SetVerboseLogging(_initSpec.isDebug);
 | 
				
			||||||
            InitService();
 | 
					            InitService();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,16 +93,16 @@ namespace Guru
 | 
				
			||||||
        private void OnMaxSdkInitializedCallBack(MaxSdkBase.SdkConfiguration sdkConfiguration)
 | 
					        private void OnMaxSdkInitializedCallBack(MaxSdkBase.SdkConfiguration sdkConfiguration)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            this.Log("AD SDK Init Success");
 | 
					            this.Log("AD SDK Init Success");
 | 
				
			||||||
            if (_isAutoLoadAds) OnMaxSdkReady();
 | 
					            if (_initSpec.autoLoad) OnMaxSdkReady();
 | 
				
			||||||
            _onSdkInitReady?.Invoke();
 | 
					            _onSdkInitReady?.Invoke();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        protected virtual void OnMaxSdkReady()
 | 
					        protected virtual void OnMaxSdkReady()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //TODO:各个项目根据自己情况进行修改,模版默认做法是SDK初始化完成后就进行广告请求
 | 
					            //应用启动策略
 | 
				
			||||||
            RequestBannerAD();
 | 
					            if(_initSpec.loadBanner) RequestBannerAD();
 | 
				
			||||||
            RequestInterstitialAD();
 | 
					            if(_initSpec.loadInterstitial) RequestInterstitialAD();
 | 
				
			||||||
            RequestRewardedAD();
 | 
					            if(_initSpec.loadRewarded) RequestRewardedAD();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
| 
						 | 
					@ -115,6 +114,13 @@ namespace Guru
 | 
				
			||||||
            return IsInitialized && IsNetworkEnabled;
 | 
					            return IsInitialized && IsNetworkEnabled;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool IsBuyNoAds
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _model.BuyNoAds;
 | 
				
			||||||
 | 
					            set=> _model.BuyNoAds = value;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #region ILRD
 | 
					        #region ILRD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private double TchAD001RevValue
 | 
					        private double TchAD001RevValue
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,36 @@
 | 
				
			||||||
 | 
					namespace Guru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class AdsInitSpec
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public bool loadBanner;
 | 
				
			||||||
 | 
					        public bool loadInterstitial;
 | 
				
			||||||
 | 
					        public bool loadRewarded;
 | 
				
			||||||
 | 
					        public bool autoLoad;
 | 
				
			||||||
 | 
					        public bool isDebug;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static AdsInitSpec Build(bool loadBanner = true, bool loadInterstitial = true, bool loadReward = true,
 | 
				
			||||||
 | 
					            bool autoLoad = true, bool isDebug = false)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return new AdsInitSpec
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                loadBanner = loadBanner,
 | 
				
			||||||
 | 
					                loadInterstitial = loadInterstitial,
 | 
				
			||||||
 | 
					                loadRewarded = loadReward,
 | 
				
			||||||
 | 
					                autoLoad = autoLoad,
 | 
				
			||||||
 | 
					                isDebug = isDebug
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        public static AdsInitSpec BuildDefault(bool autoLoad = true, bool isDebug = false)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return Build(true, true, true, autoLoad, isDebug);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        public static AdsInitSpec BuildWithNoAds(bool autoLoad = true, bool isDebug = false)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return Build(false, false, true, autoLoad, isDebug);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,3 @@
 | 
				
			||||||
 | 
					fileFormatVersion: 2
 | 
				
			||||||
 | 
					guid: 90685f9b1c664c4d917d7260f62b73ff
 | 
				
			||||||
 | 
					timeCreated: 1710494122
 | 
				
			||||||
| 
						 | 
					@ -12,6 +12,7 @@ namespace Guru
 | 
				
			||||||
        public int radsRewardCount = 0;
 | 
					        public int radsRewardCount = 0;
 | 
				
			||||||
        public double tchAd001Value = 0;
 | 
					        public double tchAd001Value = 0;
 | 
				
			||||||
        public double tchAd02Value = 0;
 | 
					        public double tchAd02Value = 0;
 | 
				
			||||||
 | 
					        public bool buyNoAds = false;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        public int RadsRewardCount
 | 
					        public int RadsRewardCount
 | 
				
			||||||
| 
						 | 
					@ -44,6 +45,17 @@ namespace Guru
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        public bool BuyNoAds
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => buyNoAds;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                buyNoAds = value;
 | 
				
			||||||
 | 
					                Save();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        private void Save() => _storage.Save();
 | 
					        private void Save() => _storage.Save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string ToJson()
 | 
					        public string ToJson()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,7 @@ namespace Guru
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        #region Lifecycle
 | 
					        #region Lifecycle
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void StartService(Action onSdkReady = null, bool autoLoad = true, bool isDebugMode = false);
 | 
					        void StartService(Action onSdkReady = null, AdsInitSpec spec = null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue