update: 更新部分SDK接口, 修复Adjust取值报错
parent
6caf2d0a78
commit
d7b6362302
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
@ -148,6 +149,8 @@ namespace Guru
|
||||||
/// <param name="data">INT类型的值</param>
|
/// <param name="data">INT类型的值</param>
|
||||||
public static void LogEvent(string eventName, Dictionary<string, dynamic> data = null)
|
public static void LogEvent(string eventName, Dictionary<string, dynamic> data = null)
|
||||||
{
|
{
|
||||||
|
UpdateAllUserProperties(); // 每次打点更新用户属性
|
||||||
|
|
||||||
string raw = "";
|
string raw = "";
|
||||||
if (data != null && data.Count > 0)
|
if (data != null && data.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -241,6 +244,25 @@ namespace Guru
|
||||||
UserProperties[key] = value;
|
UserProperties[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void UpdateAllUserProperties()
|
||||||
|
{
|
||||||
|
if (UserProperties != null && UserProperties.Count > 0)
|
||||||
|
{
|
||||||
|
var keys = UserProperties.Keys.ToArray();
|
||||||
|
int i = 0;
|
||||||
|
string key = "";
|
||||||
|
while (i < keys.Length)
|
||||||
|
{
|
||||||
|
key = keys[i];
|
||||||
|
if(!string.IsNullOrEmpty(key)) SetUserProperty(key, UserProperties[key]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
keys = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Collections;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Guru
|
namespace Guru
|
||||||
|
|
@ -12,6 +13,16 @@ namespace Guru
|
||||||
public const string Version = "1.5.0";
|
public const string Version = "1.5.0";
|
||||||
public static readonly string LOG_TAG = "Adjust";
|
public static readonly string LOG_TAG = "Adjust";
|
||||||
public static readonly float DelayTime = 1f; // 延迟启动时间
|
public static readonly float DelayTime = 1f; // 延迟启动时间
|
||||||
|
|
||||||
|
private static string _adId = "";
|
||||||
|
public static string AdId => _adId; // Google AdId
|
||||||
|
|
||||||
|
private static string _adujstId = "";
|
||||||
|
public static string AdjustId => _adujstId; // Adjust AdId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 启动服务
|
#region 启动服务
|
||||||
|
|
||||||
|
|
@ -56,23 +67,36 @@ namespace Guru
|
||||||
Adjust.start(config);
|
Adjust.start(config);
|
||||||
|
|
||||||
// 缓存标准属性
|
// 缓存标准属性
|
||||||
StandardProperties.AdjustId = Adjust.getAdid(); // 获取AdjustID
|
_adujstId = Adjust.getAdid(); // 获取AdjustID
|
||||||
|
// StandardProperties.AdjustId = _adujstId;
|
||||||
|
|
||||||
Loom.RunAsync(() =>
|
// Loom.RunAsync(() =>
|
||||||
|
// {
|
||||||
|
// Adjust.getGoogleAdId(gid =>
|
||||||
|
// {
|
||||||
|
// if (!string.IsNullOrEmpty(gid))
|
||||||
|
// {
|
||||||
|
// Loom.QueueOnMainThread(() =>
|
||||||
|
// {
|
||||||
|
// StandardProperties.GoogleAdId = gid; // 获取Google AD ID
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
FetchAdId(); // 异步加载AdId
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void FetchAdId()
|
||||||
|
{
|
||||||
|
Adjust.getGoogleAdId(gid =>
|
||||||
{
|
{
|
||||||
Adjust.getGoogleAdId(gid =>
|
if (!string.IsNullOrEmpty(gid))
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(gid))
|
_adId = gid; // 获取Google AD ID
|
||||||
{
|
}
|
||||||
Loom.QueueOnMainThread(() =>
|
|
||||||
{
|
|
||||||
StandardProperties.GoogleAdId = gid; // 获取Google AD ID
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 确保 Adjust 实例在场景中
|
/// 确保 Adjust 实例在场景中
|
||||||
|
|
@ -385,16 +409,5 @@ namespace Guru
|
||||||
adRevenue.setAdRevenuePlacement(adInfo.Placement);
|
adRevenue.setAdRevenuePlacement(adInfo.Placement);
|
||||||
Adjust.trackAdRevenue(adRevenue);
|
Adjust.trackAdRevenue(adRevenue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static string GetAdID()
|
|
||||||
{
|
|
||||||
string adid = Adjust.getAdid();
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
adid = "adjust_adid_empty_in_editor";
|
|
||||||
#endif
|
|
||||||
return adid;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -57,6 +57,10 @@ namespace Guru
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 各ID上报信息
|
#region 各ID上报信息
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -96,7 +100,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
if (_hasGotAdjustId) return;
|
if (_hasGotAdjustId) return;
|
||||||
|
|
||||||
string adjustId = AdjustService.GetAdID();
|
string adjustId = AdjustService.AdjustId;
|
||||||
if (!string.IsNullOrEmpty(adjustId)
|
if (!string.IsNullOrEmpty(adjustId)
|
||||||
&& string.IsNullOrEmpty(IPMConfig.ADJUST_ID))
|
&& string.IsNullOrEmpty(IPMConfig.ADJUST_ID))
|
||||||
{
|
{
|
||||||
|
|
@ -122,29 +126,29 @@ namespace Guru
|
||||||
{
|
{
|
||||||
if (_hasGotAdId) return;
|
if (_hasGotAdId) return;
|
||||||
|
|
||||||
|
#if UNITY_ANDROID
|
||||||
|
var adId = AdjustService.AdId;
|
||||||
|
if (!string.IsNullOrEmpty(adId))
|
||||||
|
{
|
||||||
|
// Debug.Log($"---[ANA] ADID: {adId}");
|
||||||
|
IPMConfig.ADJUST_ADID = adId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AdjustService.FetchAdId();
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
// ============= ADID is not supported on Adjust iOS API ==============
|
||||||
|
IPMConfig.ADJUST_ADID = VALUE_NOT_FOR_IOS;;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(IPMConfig.ADJUST_ADID))
|
if (!string.IsNullOrEmpty(IPMConfig.ADJUST_ADID))
|
||||||
{
|
{
|
||||||
GuruAnalytics.SetAdId(IPMConfig.ADJUST_ADID);
|
GuruAnalytics.SetAdId(IPMConfig.ADJUST_ADID);
|
||||||
_hasGotAdId = true;
|
_hasGotAdId = true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
#if UNITY_ANDROID
|
|
||||||
Adjust.getGoogleAdId(adId =>
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(adId)
|
|
||||||
&& string.IsNullOrEmpty(IPMConfig.ADJUST_ADID))
|
|
||||||
{
|
|
||||||
// Debug.Log($"---[ANA] ADID: {adId}");
|
|
||||||
IPMConfig.ADJUST_ADID = adId;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
// ============= ADID is not supported on Adjust iOS API ==============
|
|
||||||
IPMConfig.ADJUST_ADID = VALUE_NOT_FOR_IOS;
|
|
||||||
GuruAnalytics.SetAdId(IPMConfig.ADJUST_ADID);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -139,5 +139,14 @@ namespace Guru
|
||||||
delayed.action();
|
delayed.action();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请在主线程内调用启动逻辑
|
||||||
|
/// </summary>
|
||||||
|
public static void StartUp()
|
||||||
|
{
|
||||||
|
if (initialized || null != _current) return;
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue