Compare commits
No commits in common. "5c1f73fc1822ee07d4e8a5d0f73edf12c87ffa64" and "19a46fff1e067ce58618ae3071458f8e11a88dbf" have entirely different histories.
5c1f73fc18
...
19a46fff1e
|
|
@ -1,14 +1,11 @@
|
|||
|
||||
|
||||
|
||||
namespace Guru
|
||||
{
|
||||
using UnityEngine;
|
||||
using com.adjust.sdk;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
public class AdjustService
|
||||
public static class AdjustService
|
||||
{
|
||||
public const string Version = "1.6.1";
|
||||
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_SUB_PURCHASE = "sub_purchase"; // 固定点位事件
|
||||
|
||||
private static Action<string> _onSessionSuccessCallback;
|
||||
|
||||
|
||||
private static string _adId = "";
|
||||
public static string AdId
|
||||
|
|
@ -50,7 +45,7 @@ namespace Guru
|
|||
/// </summary>
|
||||
/// <param name="appToken"></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))
|
||||
{
|
||||
|
|
@ -58,8 +53,6 @@ namespace Guru
|
|||
return;
|
||||
}
|
||||
|
||||
_onSessionSuccessCallback = onSessionSuccess;
|
||||
|
||||
InstallEvent(IPMConfig.FIREBASE_ID, IPMConfig.IPM_DEVICE_ID); // 注入启动参数
|
||||
|
||||
AdjustEnvironment environment = GetAdjustEnvironment();
|
||||
|
|
@ -68,7 +61,6 @@ 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
|
||||
|
|
@ -79,7 +71,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
|
||||
|
|
@ -280,10 +272,27 @@ namespace Guru
|
|||
|
||||
private static void OnSessionSuccessCallback(AdjustSessionSuccess sessionSuccessData)
|
||||
{
|
||||
LogI(LOG_TAG,$"{LOG_TAG} --- Session tracked successfully!");
|
||||
LogI(LOG_TAG,"Session tracked successfully!");
|
||||
|
||||
var adid = sessionSuccessData.Adid;
|
||||
_onSessionSuccessCallback?.Invoke(adid);
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnSessionFailureCallback(AdjustSessionFailure sessionFailureData)
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ 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;
|
||||
|
|
@ -151,13 +149,6 @@ 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)
|
||||
|
|
@ -520,8 +511,8 @@ namespace Guru
|
|||
this.LogError(
|
||||
$"OnInterstitialFailedEvent AdLoadFailureInfo:{errorInfo.AdLoadFailureInfo}, Message: {errorInfo.Message}");
|
||||
_interstitialRetryAttempt++;
|
||||
float retryDelay = GetRetryDelaySeconds(_interstitialRetryAttempt);
|
||||
DelayCall(retryDelay, RequestInterstitialAD);
|
||||
double retryDelay = Math.Pow(2, Math.Min(3, _interstitialRetryAttempt));
|
||||
DelayCall((float)retryDelay, RequestInterstitialAD);
|
||||
// Analytics.ADIadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory);
|
||||
Analytics.ADIadsFailed(AdParams.Build(adUnitId,
|
||||
duration: GetAdsLoadDuration(ref _iadsLoadStartTime), category: _iadsCategory,
|
||||
|
|
@ -678,8 +669,8 @@ namespace Guru
|
|||
errorCode: (int)errorInfo.Code,
|
||||
waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
|
||||
_rewardRetryAttempt++;
|
||||
float retryDelay = GetRetryDelaySeconds(_rewardRetryAttempt);
|
||||
DelayCall(retryDelay, RequestRewardedAD);
|
||||
double retryDelay = Math.Pow(2, Math.Min(3, _rewardRetryAttempt));
|
||||
DelayCall((float)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,34 +117,10 @@ namespace Guru
|
|||
// 启动 AdjustService
|
||||
string appToken = GuruSettings.Instance.AdjustSetting?.GetAppToken() ?? "";
|
||||
string fbAppId = GuruSettings.Instance.IPMSetting.FacebookAppId;
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
AdjustService.StartService(appToken, fbAppId);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static void ReportAdjustId(string adjustId)
|
||||
{
|
||||
FirebaseAnalytics.SetUserProperty("adjust_id", adjustId); // 仅上报 Firebase 用户属性
|
||||
Debug.Log($"[SDK] --- Firebase + Adjust ID: {adjustId}");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue