Compare commits
	
		
			No commits in common. "5c1f73fc1822ee07d4e8a5d0f73edf12c87ffa64" and "19a46fff1e067ce58618ae3071458f8e11a88dbf" have entirely different histories. 
		
	
	
		
			5c1f73fc18
			...
			19a46fff1e
		
	
		| 
						 | 
					@ -1,14 +1,11 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Guru
 | 
					namespace Guru
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	using UnityEngine;
 | 
						using UnityEngine;
 | 
				
			||||||
	using com.adjust.sdk;
 | 
						using com.adjust.sdk;
 | 
				
			||||||
	using System;
 | 
					 | 
				
			||||||
	using System.Collections;
 | 
						using System.Collections;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public class AdjustService
 | 
						public static class AdjustService
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		public const string Version = "1.6.1";
 | 
							public const string Version = "1.6.1";
 | 
				
			||||||
		public const string AdjustVersion = "4.38.0"; // Adjust SDK Version
 | 
							public const string AdjustVersion = "4.38.0"; // Adjust SDK Version
 | 
				
			||||||
| 
						 | 
					@ -18,8 +15,6 @@ namespace Guru
 | 
				
			||||||
		public const string K_IAP_PURCHASE = "iap_purchase"; // 固定点位事件
 | 
							public const string K_IAP_PURCHASE = "iap_purchase"; // 固定点位事件
 | 
				
			||||||
		public const string K_SUB_PURCHASE = "sub_purchase"; // 固定点位事件
 | 
							public const string K_SUB_PURCHASE = "sub_purchase"; // 固定点位事件
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		private static Action<string> _onSessionSuccessCallback;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		private static string _adId = "";
 | 
							private static string _adId = "";
 | 
				
			||||||
		public static string AdId
 | 
							public static string AdId
 | 
				
			||||||
| 
						 | 
					@ -50,7 +45,7 @@ namespace Guru
 | 
				
			||||||
		/// </summary>
 | 
							/// </summary>
 | 
				
			||||||
		/// <param name="appToken"></param>
 | 
							/// <param name="appToken"></param>
 | 
				
			||||||
		/// <param name="fbAppId">MIR 追踪 AppID</param>
 | 
							/// <param name="fbAppId">MIR 追踪 AppID</param>
 | 
				
			||||||
		public static void StartService(string appToken, string fbAppId = "", Action<string> onSessionSuccess = null)
 | 
							public static void StartService(string appToken, string fbAppId = "")
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if (string.IsNullOrEmpty(appToken))
 | 
								if (string.IsNullOrEmpty(appToken))
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
| 
						 | 
					@ -58,8 +53,6 @@ namespace Guru
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			_onSessionSuccessCallback = onSessionSuccess;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			InstallEvent(IPMConfig.FIREBASE_ID, IPMConfig.IPM_DEVICE_ID); // 注入启动参数
 | 
								InstallEvent(IPMConfig.FIREBASE_ID, IPMConfig.IPM_DEVICE_ID); // 注入启动参数
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			AdjustEnvironment environment = GetAdjustEnvironment();
 | 
								AdjustEnvironment environment = GetAdjustEnvironment();
 | 
				
			||||||
| 
						 | 
					@ -68,7 +61,6 @@ namespace Guru
 | 
				
			||||||
			config.setDelayStart(DelayTime);
 | 
								config.setDelayStart(DelayTime);
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
			config.setPreinstallTrackingEnabled(true); // Adjust Preinstall
 | 
								config.setPreinstallTrackingEnabled(true); // Adjust Preinstall
 | 
				
			||||||
			config.setSessionSuccessDelegate(OnSessionSuccessCallback); // SessionSuccess
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if UNITY_ANDROID
 | 
					#if UNITY_ANDROID
 | 
				
			||||||
			if (!string.IsNullOrEmpty(fbAppId)) config.setFbAppId(fbAppId); // 注入 MIR ID
 | 
								if (!string.IsNullOrEmpty(fbAppId)) config.setFbAppId(fbAppId); // 注入 MIR ID
 | 
				
			||||||
| 
						 | 
					@ -79,7 +71,7 @@ namespace Guru
 | 
				
			||||||
			config.setLogDelegate(log => LogI(LOG_TAG, log));
 | 
								config.setLogDelegate(log => LogI(LOG_TAG, log));
 | 
				
			||||||
			config.setEventSuccessDelegate(OnEventSuccessCallback);
 | 
								config.setEventSuccessDelegate(OnEventSuccessCallback);
 | 
				
			||||||
			config.setEventFailureDelegate(OnEventFailureCallback);
 | 
								config.setEventFailureDelegate(OnEventFailureCallback);
 | 
				
			||||||
			
 | 
								config.setSessionSuccessDelegate(OnSessionSuccessCallback);
 | 
				
			||||||
			config.setSessionFailureDelegate(OnSessionFailureCallback);
 | 
								config.setSessionFailureDelegate(OnSessionFailureCallback);
 | 
				
			||||||
			config.setAttributionChangedDelegate(OnAttributionChangedCallback);
 | 
								config.setAttributionChangedDelegate(OnAttributionChangedCallback);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -280,10 +272,27 @@ namespace Guru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		private static void OnSessionSuccessCallback(AdjustSessionSuccess sessionSuccessData)
 | 
							private static void OnSessionSuccessCallback(AdjustSessionSuccess sessionSuccessData)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			LogI(LOG_TAG,$"{LOG_TAG} --- Session tracked successfully!");
 | 
								LogI(LOG_TAG,"Session tracked successfully!");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			var adid = sessionSuccessData.Adid;
 | 
								if (sessionSuccessData.Message != null)
 | 
				
			||||||
			_onSessionSuccessCallback?.Invoke(adid);
 | 
								{
 | 
				
			||||||
 | 
									LogI(LOG_TAG,"Message: " + sessionSuccessData.Message);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (sessionSuccessData.Timestamp != null)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									LogI(LOG_TAG,"Timestamp: " + sessionSuccessData.Timestamp);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (sessionSuccessData.Adid != null)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									LogI(LOG_TAG, "Adid: " + sessionSuccessData.Adid);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (sessionSuccessData.JsonResponse != null)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									LogI(LOG_TAG, "JsonResponse: " + sessionSuccessData.GetJsonResponse());
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		private static void OnSessionFailureCallback(AdjustSessionFailure sessionFailureData)
 | 
							private static void OnSessionFailureCallback(AdjustSessionFailure sessionFailureData)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,8 +22,6 @@ namespace Guru
 | 
				
			||||||
        public bool IsInitialized => MaxSdk.IsInitialized() || _isServiceStarted;
 | 
					        public bool IsInitialized => MaxSdk.IsInitialized() || _isServiceStarted;
 | 
				
			||||||
        protected bool IsNetworkEnabled => Application.internetReachability != NetworkReachability.NotReachable;
 | 
					        protected bool IsNetworkEnabled => Application.internetReachability != NetworkReachability.NotReachable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private const int MAX_ADS_RELOAD_INTERVAL = 6; // 广告加载最高时间为 2 的 6 次方 = 64秒
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _isServiceStarted;
 | 
					        private bool _isServiceStarted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        protected Action _onSdkInitReady;
 | 
					        protected Action _onSdkInitReady;
 | 
				
			||||||
| 
						 | 
					@ -151,13 +149,6 @@ namespace Guru
 | 
				
			||||||
            set => Model.BuyNoAds = value;
 | 
					            set => Model.BuyNoAds = value;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private float GetRetryDelaySeconds(int retryCount)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 最低 2^retryCount 秒
 | 
					 | 
				
			||||||
            // 最高 2^6 = 64 秒
 | 
					 | 
				
			||||||
            return (float)Math.Pow(2, Math.Min(MAX_ADS_RELOAD_INTERVAL, retryCount));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        #region Lifecycele
 | 
					        #region Lifecycele
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        public void OnAppPaused(bool paused)
 | 
					        public void OnAppPaused(bool paused)
 | 
				
			||||||
| 
						 | 
					@ -520,8 +511,8 @@ namespace Guru
 | 
				
			||||||
            this.LogError(
 | 
					            this.LogError(
 | 
				
			||||||
                $"OnInterstitialFailedEvent AdLoadFailureInfo:{errorInfo.AdLoadFailureInfo}, Message: {errorInfo.Message}");
 | 
					                $"OnInterstitialFailedEvent AdLoadFailureInfo:{errorInfo.AdLoadFailureInfo}, Message: {errorInfo.Message}");
 | 
				
			||||||
            _interstitialRetryAttempt++;
 | 
					            _interstitialRetryAttempt++;
 | 
				
			||||||
            float retryDelay = GetRetryDelaySeconds(_interstitialRetryAttempt);
 | 
					            double retryDelay = Math.Pow(2, Math.Min(3, _interstitialRetryAttempt));
 | 
				
			||||||
            DelayCall(retryDelay, RequestInterstitialAD);
 | 
					            DelayCall((float)retryDelay, RequestInterstitialAD);
 | 
				
			||||||
            // Analytics.ADIadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory);
 | 
					            // Analytics.ADIadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory);
 | 
				
			||||||
            Analytics.ADIadsFailed(AdParams.Build(adUnitId,
 | 
					            Analytics.ADIadsFailed(AdParams.Build(adUnitId,
 | 
				
			||||||
                duration: GetAdsLoadDuration(ref _iadsLoadStartTime), category: _iadsCategory,
 | 
					                duration: GetAdsLoadDuration(ref _iadsLoadStartTime), category: _iadsCategory,
 | 
				
			||||||
| 
						 | 
					@ -678,8 +669,8 @@ namespace Guru
 | 
				
			||||||
                errorCode: (int)errorInfo.Code,
 | 
					                errorCode: (int)errorInfo.Code,
 | 
				
			||||||
                waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
 | 
					                waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
 | 
				
			||||||
            _rewardRetryAttempt++;
 | 
					            _rewardRetryAttempt++;
 | 
				
			||||||
            float retryDelay = GetRetryDelaySeconds(_rewardRetryAttempt);
 | 
					            double retryDelay = Math.Pow(2, Math.Min(3, _rewardRetryAttempt));
 | 
				
			||||||
            DelayCall(retryDelay, RequestRewardedAD);
 | 
					            DelayCall((float)retryDelay, RequestRewardedAD);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            OnRewardFailed?.Invoke();
 | 
					            OnRewardFailed?.Invoke();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,8 @@
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using Firebase;
 | 
					using Firebase;
 | 
				
			||||||
using Firebase.Analytics;
 | 
					using Firebase.Analytics;
 | 
				
			||||||
using Firebase.Extensions;
 | 
					using Firebase.Extensions;
 | 
				
			||||||
using UnityEngine;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Guru
 | 
					namespace Guru
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -117,34 +117,10 @@ namespace Guru
 | 
				
			||||||
					// 启动 AdjustService
 | 
										// 启动 AdjustService
 | 
				
			||||||
					string appToken = GuruSettings.Instance.AdjustSetting?.GetAppToken() ?? "";
 | 
										string appToken = GuruSettings.Instance.AdjustSetting?.GetAppToken() ?? "";
 | 
				
			||||||
					string fbAppId = GuruSettings.Instance.IPMSetting.FacebookAppId;
 | 
										string fbAppId = GuruSettings.Instance.IPMSetting.FacebookAppId;
 | 
				
			||||||
 | 
										AdjustService.StartService(appToken, fbAppId);  
 | 
				
			||||||
					if (!string.IsNullOrEmpty(IPMConfig.ADJUST_ID))
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						ReportAdjustId(IPMConfig.ADJUST_ID); // 二次启动后,若有值则立即上报属性
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					AdjustService.StartService(appToken, fbAppId, adjustId =>
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						// 获取 ADID 
 | 
					 | 
				
			||||||
						if (string.IsNullOrEmpty(adjustId))
 | 
					 | 
				
			||||||
						{
 | 
					 | 
				
			||||||
							adjustId = "not_set";
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						else
 | 
					 | 
				
			||||||
						{
 | 
					 | 
				
			||||||
							IPMConfig.ADJUST_ID = adjustId;
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						ReportAdjustId(adjustId);
 | 
					 | 
				
			||||||
					});  
 | 
					 | 
				
			||||||
					
 | 
					 | 
				
			||||||
				});
 | 
									});
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
		private static void ReportAdjustId(string adjustId)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			FirebaseAnalytics.SetUserProperty("adjust_id", adjustId); // 仅上报 Firebase 用户属性
 | 
					 | 
				
			||||||
			Debug.Log($"[SDK] --- Firebase + Adjust ID: {adjustId}");
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue