Merge branch 'main' of http://v4.9ms.co:7777/yufeng/SDK_UnityMoney
This commit is contained in:
commit
f38e306cf4
|
@ -7,17 +7,19 @@ using WZ;
|
|||
|
||||
public class AdjustManager : D_MonoSingleton<AdjustManager>
|
||||
{
|
||||
private string appToken = "cap3ypurzegw"; // 替换为你的实际App Token
|
||||
private AdjustEnvironment environment = AdjustEnvironment.Sandbox; // 测试用Sandbox,发布用Production
|
||||
|
||||
private long startTime = 0;
|
||||
|
||||
private string Adid;
|
||||
private string Gdid;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
//开始计时
|
||||
startTime = TimeUtils.GetLocalTimestamp();
|
||||
|
||||
AdjustConfig config = new AdjustConfig(appToken, environment);
|
||||
AdjustConfig config = new AdjustConfig(StaticValue.AdjustToken, environment);
|
||||
|
||||
// 设置归因变更回调函数
|
||||
config.AttributionChangedDelegate = AttributionChangedDelegate;
|
||||
|
@ -28,6 +30,10 @@ public class AdjustManager : D_MonoSingleton<AdjustManager>
|
|||
// 初始化Adjust SDK
|
||||
Adjust.InitSdk(config);
|
||||
|
||||
//id
|
||||
LoadAdid();
|
||||
LoadGaid();
|
||||
|
||||
//计时3分钟
|
||||
AppSDKManager.Instance.Coroutine(AdjustNetwork.Instance.SetOrganic3Min());
|
||||
|
||||
|
@ -50,5 +56,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,11 +1,48 @@
|
|||
using AdjustSdk;
|
||||
using Firebase.RemoteConfig;
|
||||
using System.Collections.Generic;
|
||||
using AdjustSdk;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using WZ;
|
||||
|
||||
|
||||
public class AdjustTrackEvent : D_MonoSingleton<AdjustTrackEvent>
|
||||
{
|
||||
private Dictionary<string, string> eventTokenMap;
|
||||
|
||||
|
||||
private string GetEventToken(string eventName)
|
||||
{
|
||||
if (eventTokenMap == null)
|
||||
{
|
||||
UpdateEventToken();
|
||||
}
|
||||
|
||||
if (eventTokenMap == null || eventTokenMap.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return eventTokenMap.GetValueOrDefault(eventName, null);
|
||||
}
|
||||
|
||||
public void UpdateEventToken()
|
||||
{
|
||||
var remoteConfigString = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("event_adjust_set");
|
||||
if (string.IsNullOrEmpty(remoteConfigString)) return;
|
||||
|
||||
var deserializeObject = JsonConvert.DeserializeObject<Dictionary<string, string>>(remoteConfigString);
|
||||
if (eventTokenMap == null)
|
||||
{
|
||||
eventTokenMap = deserializeObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var keyValuePair in deserializeObject)
|
||||
{
|
||||
eventTokenMap[keyValuePair.Key] = keyValuePair.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// adjust事件上报
|
||||
/// </summary>
|
||||
|
@ -16,6 +53,32 @@ public class AdjustTrackEvent : D_MonoSingleton<AdjustTrackEvent>
|
|||
Adjust.TrackEvent(adjustEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 会将eventName 转化成 token 进行上报
|
||||
/// </summary>
|
||||
/// <param name="eventName"></param>
|
||||
/// <param name="extraInfo"></param>
|
||||
public void TrackEventName(string eventName, Dictionary<string, object> extraInfo)
|
||||
{
|
||||
var eventToken = GetEventToken(eventName);
|
||||
if (string.IsNullOrEmpty(eventToken))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var adjustEvent = new AdjustEvent(eventToken);
|
||||
if (extraInfo != null)
|
||||
{
|
||||
foreach (var keyValuePair in extraInfo)
|
||||
{
|
||||
adjustEvent.AddPartnerParameter(keyValuePair.Key, keyValuePair.Value.ToString());
|
||||
adjustEvent.AddCallbackParameter(keyValuePair.Key, keyValuePair.Value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
Adjust.TrackEvent(adjustEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 广告收益上报
|
||||
/// </summary>
|
||||
|
@ -42,11 +105,12 @@ public class AdjustTrackEvent : D_MonoSingleton<AdjustTrackEvent>
|
|||
{
|
||||
string source = "applovin_max_sdk";
|
||||
//获取在线参数
|
||||
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("revenue_adj");
|
||||
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("revenue_adj");
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
var revenueAdjs = JsonConvert.DeserializeObject<RevenueData[]>(json);
|
||||
if (revenueAdjs == null && revenueAdjs.Length == 0)
|
||||
{
|
||||
|
@ -59,8 +123,9 @@ public class AdjustTrackEvent : D_MonoSingleton<AdjustTrackEvent>
|
|||
{
|
||||
totalRate += item.rate;
|
||||
}
|
||||
|
||||
//开始随机
|
||||
int randomValue = UnityEngine.Random.Range(0, totalRate);
|
||||
int randomValue = Random.Range(0, totalRate);
|
||||
int accumulatedRate = 0;
|
||||
|
||||
//根据随机值定位
|
||||
|
|
|
@ -42,13 +42,14 @@ namespace WZ
|
|||
//
|
||||
MobileAds.Initialize(initStatus =>
|
||||
{
|
||||
if (_bannerAdUnits.Count > 0) LoadBanner();
|
||||
if (_interstitialAdUnits.Count > 0) LoadInterstitial();
|
||||
if (_rewardedAdUnits.Count > 0) LoadRewarded();
|
||||
if(_splashAdUnits.Count > 0) AdsSplashManager.Instance.InitSplash();
|
||||
LoggerUtils.Debug("[Admob] init success");
|
||||
});
|
||||
|
||||
if (_bannerAdUnits.Count > 0) LoadBanner();
|
||||
if (_interstitialAdUnits.Count > 0) LoadInterstitial();
|
||||
if (_rewardedAdUnits.Count > 0) LoadRewarded();
|
||||
if(_splashAdUnits.Count > 0) AdsSplashManager.Instance.InitSplash();
|
||||
|
||||
if (_nativeAdUnits.Count > 0)
|
||||
{
|
||||
LoadNative();
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using AdjustSdk;
|
||||
using EFSDK;
|
||||
using Firebase.RemoteConfig;
|
||||
using GoogleMobileAds.Api;
|
||||
using Newtonsoft.Json;
|
||||
using ThinkingAnalytics;
|
||||
using UnityEngine;
|
||||
using WZ;
|
||||
|
||||
|
@ -132,22 +135,118 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
|
||||
public bool IsNativeFullReady()
|
||||
{
|
||||
return false;
|
||||
var adUnitId = StaticValue.AdmobFullNativeId;
|
||||
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
||||
}
|
||||
|
||||
public void ShowFullNative(string position, Action<bool, double> callback = null)
|
||||
public void ShowFullNative(RectTransform rectTransform, Camera pCom = null, string position = "")
|
||||
{
|
||||
if (!IsNativeFullReady())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var adUnitId = StaticValue.AdmobFullNativeId;
|
||||
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
||||
{
|
||||
TemplateId = NativeTemplateId.Medium,
|
||||
MainBackgroundColor = Color.white
|
||||
}, rectTransform, pCom);
|
||||
|
||||
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
||||
}
|
||||
|
||||
public void ShowNative(RectTransform rectTransform, Camera camera = null, string position = "")
|
||||
public void HideFullNative()
|
||||
{
|
||||
var adUnitId = StaticValue.AdmobFullNativeId;
|
||||
AdsSDKManager.Instance.RemoveNativeAd(adUnitId);
|
||||
}
|
||||
|
||||
public bool IsNativeReady()
|
||||
{
|
||||
var adUnitId = StaticValue.AdmobNativeId;
|
||||
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
||||
}
|
||||
|
||||
public void ShowNative(RectTransform rectTransform, Camera pCom = null, string position = "")
|
||||
{
|
||||
if (!IsNativeReady())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var adUnitId = StaticValue.AdmobNativeId;
|
||||
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
||||
{
|
||||
TemplateId = NativeTemplateId.Medium,
|
||||
MainBackgroundColor = Color.white
|
||||
}, rectTransform, pCom);
|
||||
|
||||
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
||||
}
|
||||
|
||||
public void HideNative()
|
||||
{
|
||||
var adUnitId = StaticValue.AdmobNativeId;
|
||||
AdsSDKManager.Instance.RemoveNativeAd(adUnitId);
|
||||
}
|
||||
|
||||
public bool IsSmallNativeReady()
|
||||
{
|
||||
var adUnitId = StaticValue.AdmobSmallNativeId;
|
||||
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
||||
}
|
||||
|
||||
public void ShowSmallNative(RectTransform rectTransform, Camera pCom = null, string position = "")
|
||||
{
|
||||
if (!IsSmallNativeReady())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var adUnitId = StaticValue.AdmobSmallNativeId;
|
||||
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
||||
{
|
||||
TemplateId = NativeTemplateId.Medium,
|
||||
MainBackgroundColor = Color.white
|
||||
}, rectTransform, pCom);
|
||||
|
||||
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
||||
}
|
||||
|
||||
public void HideSmallNative()
|
||||
{
|
||||
var adUnitId = StaticValue.AdmobSmallNativeId;
|
||||
AdsSDKManager.Instance.RemoveNativeAd(adUnitId);
|
||||
}
|
||||
|
||||
public bool IsMinddleNativeReady()
|
||||
{
|
||||
var adUnitId = StaticValue.AdmobMinddleNativeId;
|
||||
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
||||
}
|
||||
|
||||
public void ShowMinddleNative(RectTransform rectTransform, Camera pCom = null, string position = "")
|
||||
{
|
||||
if (!IsSmallNativeReady())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var adUnitId = StaticValue.AdmobMinddleNativeId;
|
||||
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
||||
{
|
||||
TemplateId = NativeTemplateId.Medium,
|
||||
MainBackgroundColor = Color.white
|
||||
}, rectTransform, pCom);
|
||||
|
||||
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
||||
}
|
||||
|
||||
public void HideMinddleNative()
|
||||
{
|
||||
var adUnitId = StaticValue.AdmobMinddleNativeId;
|
||||
AdsSDKManager.Instance.RemoveNativeAd(adUnitId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -158,18 +257,25 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
{
|
||||
ShuShuEvent.Instance.Track(eventName);
|
||||
FireBaseAnalyticsManager.Instance.LogEvent(eventName);
|
||||
AdjustTrackEvent.Instance.TrackEventName(eventName, new Dictionary<string, object>());
|
||||
}
|
||||
|
||||
public void LogEvent(string eventName, string key1, object value1)
|
||||
{
|
||||
ShuShuEvent.Instance.Track(eventName, key1, value1);
|
||||
FireBaseAnalyticsManager.Instance.LogEvent(eventName, key1, value1);
|
||||
AdjustTrackEvent.Instance.TrackEventName(eventName, new Dictionary<string, object>
|
||||
{
|
||||
[key1] = value1
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void LogEvent(string eventName, Dictionary<string, object> extraInfo)
|
||||
{
|
||||
ShuShuEvent.Instance.Track(eventName, extraInfo);
|
||||
FireBaseAnalyticsManager.Instance.LogEvent(eventName, extraInfo);
|
||||
AdjustTrackEvent.Instance.TrackEventName(eventName, extraInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -564,38 +670,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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,18 +8,17 @@ namespace WZ
|
|||
{
|
||||
public class FireBaseRemoteConfigManager : D_MonoSingleton<FireBaseRemoteConfigManager>
|
||||
{
|
||||
public bool IsInitialized { get; private set; }
|
||||
public void FetchRemoteConfig()
|
||||
{
|
||||
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
|
||||
{
|
||||
if (task.Result == Firebase.DependencyStatus.Available)
|
||||
{
|
||||
// Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
|
||||
// {
|
||||
// if (task.Result == Firebase.DependencyStatus.Available)
|
||||
// {
|
||||
Firebase.RemoteConfig.FirebaseRemoteConfig.DefaultInstance.FetchAsync(TimeSpan.Zero).ContinueWithOnMainThread(task =>
|
||||
{
|
||||
FirebaseRemoteConfig.DefaultInstance.ActivateAsync().ContinueWithOnMainThread(task =>
|
||||
{
|
||||
IsInitialized = true;
|
||||
AdjustTrackEvent.Instance.UpdateEventToken();
|
||||
// 获取广告位信息
|
||||
AdConfigParser.Parse(GetRemoteConfigString("ad_config"));
|
||||
// 刷新广告位信息
|
||||
|
@ -38,8 +37,8 @@ namespace WZ
|
|||
// 检查Adjust归因
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private void GroupSet()
|
||||
|
|
|
@ -11,10 +11,10 @@ namespace WZ
|
|||
{
|
||||
public void Init()
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// if (Application.isEditor)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
InitSDK();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,10 @@ namespace WZ
|
|||
{
|
||||
public class ShuShuMangage : D_MonoSingleton<ShuShuMangage>
|
||||
{
|
||||
private const string appid = "80f6819a81c743cbad667ecf242f3133";
|
||||
private const string server = "https://global-receiver-ta.thinkingdata.cn";
|
||||
|
||||
public void Init()
|
||||
{
|
||||
// 初始化SDK
|
||||
TDAnalytics.Init(appid, server);
|
||||
TDAnalytics.Init(StaticValue.TDAppID, StaticValue.TDServerURL);
|
||||
//开启自动采集事件
|
||||
TDAnalytics.EnableAutoTrack(TDAutoTrackEventType.AppInstall | TDAutoTrackEventType.AppStart | TDAutoTrackEventType.AppEnd);
|
||||
//如果用户已登录,可以设置用户的账号ID作为身份唯一标识
|
||||
|
|
Loading…
Reference in New Issue