using System.Collections; using System.Collections.Generic; using AdjustSdk; using Unity.VisualScripting; using UnityEngine; using WZ; public class AdjustManager : D_MonoSingleton { private AdjustEnvironment environment = AdjustEnvironment.Sandbox; // 测试用Sandbox,发布用Production private long startTime = 0; private string Adid; private string Gdid; private string _adNetwork = "_adNetwork"; private string _campaign = "_campaign"; private string _adgroup = "_adgroup"; private string _creative = "_creative"; public void Init() { //开始计时 startTime = TimeUtils.GetLocalTimestamp(); AdjustConfig config = new AdjustConfig(StaticValue.AdjustToken, environment); // 设置归因变更回调函数 config.AttributionChangedDelegate = AttributionChangedDelegate; // (可选)设置其他配置,如日志级别 config.LogLevel = AdjustLogLevel.Verbose; // 初始化Adjust SDK Adjust.InitSdk(config); //id LoadAdid(); LoadGaid(); //计时3分钟 AppSDKManager.Instance.Coroutine(AdjustNetwork.Instance.SetOrganic3Min()); ShuShuEvent.Instance.Track("adjust_init"); FireBaseAnalyticsManager.Instance.LogEvent("adjust_init"); } /// /// 归因信息 /// /// private void AttributionChangedDelegate(AdjustAttribution attribution) { Debug.Log("Attribution changed network: " + attribution.Network + " campaign: " + attribution.Campaign + " adgroup: " + attribution.Adgroup + " creative: " + attribution.Creative); AdjustNetwork.Instance.SetNetwork(attribution.Network); SaveProperties(attribution); } private void SaveProperties(AdjustAttribution attribution) { PlayerPrefsUtils.SavePlayerPrefsString(_adNetwork, attribution.Network.Substring(0, 10)); PlayerPrefsUtils.SavePlayerPrefsString(_campaign, attribution.Campaign.Substring(0, 20)); PlayerPrefsUtils.SavePlayerPrefsString(_adgroup, attribution.Adgroup.Substring(0, 10)); PlayerPrefsUtils.SavePlayerPrefsString(_creative, attribution.Creative.Substring(0, 20)); } public static string GetAdNetwork() { return PlayerPrefsUtils.GetPlayerPrefsString(AdjustManager.Instance._adNetwork, ""); } public static string GetCampaign() { return PlayerPrefsUtils.GetPlayerPrefsString(AdjustManager.Instance._campaign, ""); } public static string GetAdgroup() { return PlayerPrefsUtils.GetPlayerPrefsString(AdjustManager.Instance._adgroup, ""); } public static string GetCreative() { return PlayerPrefsUtils.GetPlayerPrefsString(AdjustManager.Instance._creative, ""); } public long GetStartTime() { 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; } }