各种id接口
This commit is contained in:
parent
1b38fceda1
commit
79ad7c8950
|
@ -12,6 +12,9 @@ public class AdjustManager : D_MonoSingleton<AdjustManager>
|
|||
|
||||
private long startTime = 0;
|
||||
|
||||
private string Adid;
|
||||
private string Gdid;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
//开始计时
|
||||
|
@ -28,6 +31,10 @@ public class AdjustManager : D_MonoSingleton<AdjustManager>
|
|||
// 初始化Adjust SDK
|
||||
Adjust.InitSdk(config);
|
||||
|
||||
//id
|
||||
LoadAdid();
|
||||
LoadGaid();
|
||||
|
||||
//计时3分钟
|
||||
AppSDKManager.Instance.Coroutine(AdjustNetwork.Instance.SetOrganic3Min());
|
||||
|
||||
|
@ -50,5 +57,28 @@ public class AdjustManager : D_MonoSingleton<AdjustManager>
|
|||
return startTime;
|
||||
}
|
||||
|
||||
private void LoadGaid()
|
||||
{
|
||||
Adjust.GetGoogleAdId(googleAdId => {
|
||||
Gdid = googleAdId;
|
||||
});
|
||||
}
|
||||
|
||||
public string GetGdid()
|
||||
{
|
||||
return Gdid;
|
||||
}
|
||||
|
||||
private void LoadAdid()
|
||||
{
|
||||
Adjust.GetAdid(adid =>
|
||||
{
|
||||
Adid = adid;
|
||||
});
|
||||
}
|
||||
|
||||
public string GetAdid()
|
||||
{
|
||||
return Adid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using AdjustSdk;
|
||||
using EFSDK;
|
||||
using Firebase.RemoteConfig;
|
||||
using Newtonsoft.Json;
|
||||
using ThinkingAnalytics;
|
||||
using UnityEngine;
|
||||
using WZ;
|
||||
|
||||
|
@ -564,38 +566,99 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
return AdjustNetwork.Instance.InOrganic();
|
||||
}
|
||||
|
||||
public string GetGaid()
|
||||
public string GetGaid()
|
||||
{
|
||||
return null;
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return "gaid";
|
||||
}
|
||||
return AdjustManager.Instance.GetGdid();
|
||||
}
|
||||
|
||||
public string GetAndroidId()
|
||||
{
|
||||
return null;
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return "androidid";
|
||||
}
|
||||
string androidId = "unknown";
|
||||
try
|
||||
{
|
||||
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
||||
using (AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
|
||||
using (AndroidJavaClass settingsSecure = new AndroidJavaClass("android.provider.Settings$Secure"))
|
||||
{
|
||||
// 调用 Settings.Secure.getString() 方法获取 ANDROID_ID
|
||||
androidId = settingsSecure.CallStatic<string>(
|
||||
"getString",
|
||||
currentActivity.Call<AndroidJavaObject>("getContentResolver"),
|
||||
"android_id"
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
LoggerUtils.Error("获取 Android ID 出错: " + e.Message);
|
||||
}
|
||||
return androidId;
|
||||
}
|
||||
|
||||
public string GetAdid()
|
||||
{
|
||||
return null;
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return "adid";
|
||||
}
|
||||
return AdjustManager.Instance.GetAdid();
|
||||
}
|
||||
|
||||
public string GetUserAgent()
|
||||
{
|
||||
return null;
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return "GetUserAgent";
|
||||
}
|
||||
try
|
||||
{
|
||||
// 获取Java的System类
|
||||
using (AndroidJavaClass systemClass = new AndroidJavaClass("java.lang.System"))
|
||||
{
|
||||
// 调用System.getProperty("http.agent")方法
|
||||
string httpAgent = systemClass.CallStatic<string>("getProperty", "http.agent");
|
||||
return httpAgent;
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError("获取http.agent失败: " + e.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetSSAccountId()
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return "GetSSAccountId";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetSSDistinctId()
|
||||
{
|
||||
return null;
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return "GetSSDistinctId";
|
||||
}
|
||||
return ThinkingAnalyticsAPI.GetDistinctId();;
|
||||
}
|
||||
|
||||
public string GetSSSuperProperties()
|
||||
{
|
||||
return null;
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return "GetSSSuperProperties";
|
||||
}
|
||||
return ThinkingAnalyticsAPI.GetSuperProperties().ToString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue