Compare commits
4 Commits
19a46fff1e
...
5c1f73fc18
| Author | SHA1 | Date |
|---|---|---|
|
|
5c1f73fc18 | |
|
|
8a81ed78b4 | |
|
|
76fc4f5c26 | |
|
|
72bf076537 |
|
|
@ -1,11 +1,14 @@
|
|||
|
||||
|
||||
|
||||
namespace Guru
|
||||
{
|
||||
using UnityEngine;
|
||||
using com.adjust.sdk;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
public static class AdjustService
|
||||
public class AdjustService
|
||||
{
|
||||
public const string Version = "1.6.1";
|
||||
public const string AdjustVersion = "4.38.0"; // Adjust SDK Version
|
||||
|
|
@ -15,6 +18,8 @@ namespace Guru
|
|||
public const string K_IAP_PURCHASE = "iap_purchase"; // 固定点位事件
|
||||
public const string K_SUB_PURCHASE = "sub_purchase"; // 固定点位事件
|
||||
|
||||
private static Action<string> _onSessionSuccessCallback;
|
||||
|
||||
|
||||
private static string _adId = "";
|
||||
public static string AdId
|
||||
|
|
@ -45,7 +50,7 @@ namespace Guru
|
|||
/// </summary>
|
||||
/// <param name="appToken"></param>
|
||||
/// <param name="fbAppId">MIR 追踪 AppID</param>
|
||||
public static void StartService(string appToken, string fbAppId = "")
|
||||
public static void StartService(string appToken, string fbAppId = "", Action<string> onSessionSuccess = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(appToken))
|
||||
{
|
||||
|
|
@ -53,6 +58,8 @@ namespace Guru
|
|||
return;
|
||||
}
|
||||
|
||||
_onSessionSuccessCallback = onSessionSuccess;
|
||||
|
||||
InstallEvent(IPMConfig.FIREBASE_ID, IPMConfig.IPM_DEVICE_ID); // 注入启动参数
|
||||
|
||||
AdjustEnvironment environment = GetAdjustEnvironment();
|
||||
|
|
@ -61,6 +68,7 @@ namespace Guru
|
|||
config.setDelayStart(DelayTime);
|
||||
|
||||
config.setPreinstallTrackingEnabled(true); // Adjust Preinstall
|
||||
config.setSessionSuccessDelegate(OnSessionSuccessCallback); // SessionSuccess
|
||||
|
||||
#if UNITY_ANDROID
|
||||
if (!string.IsNullOrEmpty(fbAppId)) config.setFbAppId(fbAppId); // 注入 MIR ID
|
||||
|
|
@ -71,7 +79,7 @@ namespace Guru
|
|||
config.setLogDelegate(log => LogI(LOG_TAG, log));
|
||||
config.setEventSuccessDelegate(OnEventSuccessCallback);
|
||||
config.setEventFailureDelegate(OnEventFailureCallback);
|
||||
config.setSessionSuccessDelegate(OnSessionSuccessCallback);
|
||||
|
||||
config.setSessionFailureDelegate(OnSessionFailureCallback);
|
||||
config.setAttributionChangedDelegate(OnAttributionChangedCallback);
|
||||
#endif
|
||||
|
|
@ -272,27 +280,10 @@ namespace Guru
|
|||
|
||||
private static void OnSessionSuccessCallback(AdjustSessionSuccess sessionSuccessData)
|
||||
{
|
||||
LogI(LOG_TAG,"Session tracked successfully!");
|
||||
LogI(LOG_TAG,$"{LOG_TAG} --- Session tracked successfully!");
|
||||
|
||||
if (sessionSuccessData.Message != null)
|
||||
{
|
||||
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());
|
||||
}
|
||||
var adid = sessionSuccessData.Adid;
|
||||
_onSessionSuccessCallback?.Invoke(adid);
|
||||
}
|
||||
|
||||
private static void OnSessionFailureCallback(AdjustSessionFailure sessionFailureData)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ namespace Guru
|
|||
public bool IsInitialized => MaxSdk.IsInitialized() || _isServiceStarted;
|
||||
protected bool IsNetworkEnabled => Application.internetReachability != NetworkReachability.NotReachable;
|
||||
|
||||
private const int MAX_ADS_RELOAD_INTERVAL = 6; // 广告加载最高时间为 2 的 6 次方 = 64秒
|
||||
|
||||
private bool _isServiceStarted;
|
||||
|
||||
protected Action _onSdkInitReady;
|
||||
|
|
@ -149,6 +151,13 @@ namespace Guru
|
|||
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
|
||||
|
||||
public void OnAppPaused(bool paused)
|
||||
|
|
@ -511,8 +520,8 @@ namespace Guru
|
|||
this.LogError(
|
||||
$"OnInterstitialFailedEvent AdLoadFailureInfo:{errorInfo.AdLoadFailureInfo}, Message: {errorInfo.Message}");
|
||||
_interstitialRetryAttempt++;
|
||||
double retryDelay = Math.Pow(2, Math.Min(3, _interstitialRetryAttempt));
|
||||
DelayCall((float)retryDelay, RequestInterstitialAD);
|
||||
float retryDelay = GetRetryDelaySeconds(_interstitialRetryAttempt);
|
||||
DelayCall(retryDelay, RequestInterstitialAD);
|
||||
// Analytics.ADIadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory);
|
||||
Analytics.ADIadsFailed(AdParams.Build(adUnitId,
|
||||
duration: GetAdsLoadDuration(ref _iadsLoadStartTime), category: _iadsCategory,
|
||||
|
|
@ -669,8 +678,8 @@ namespace Guru
|
|||
errorCode: (int)errorInfo.Code,
|
||||
waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
|
||||
_rewardRetryAttempt++;
|
||||
double retryDelay = Math.Pow(2, Math.Min(3, _rewardRetryAttempt));
|
||||
DelayCall((float)retryDelay, RequestRewardedAD);
|
||||
float retryDelay = GetRetryDelaySeconds(_rewardRetryAttempt);
|
||||
DelayCall(retryDelay, RequestRewardedAD);
|
||||
|
||||
OnRewardFailed?.Invoke();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Firebase;
|
||||
using Firebase.Analytics;
|
||||
using Firebase.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Guru
|
||||
{
|
||||
|
|
@ -117,10 +117,34 @@ namespace Guru
|
|||
// 启动 AdjustService
|
||||
string appToken = GuruSettings.Instance.AdjustSetting?.GetAppToken() ?? "";
|
||||
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