鸿蒙首次启动事件打点

main
zhangaotian 2026-06-18 16:25:03 +08:00
parent 029408b6e9
commit 5414137f3c
1 changed files with 26 additions and 0 deletions

View File

@ -4,6 +4,7 @@ using PhxhSDK.AOT;
using PhxhSDK.AOT.SimpleLoader;
using PhxhSDK.AOT.VersionUpdate;
using System;
using System.IO;
#if UNITY_IOS && !UNITY_EDITOR
using System.Runtime.InteropServices;
#endif
@ -164,6 +165,7 @@ public class GameLauncher : MonoBehaviour
versionUpdateUI.ShowVersion(Application.version, localInfo.workSpace, displayLocalVersion, acquiring, acquiring);
BIToolinAOT.Instance.Init();//TalkingData初始化
TrackHarmonyFirstStart();
try
{
DeviceIdHandle.Instance.Initialize();//设备ID获取初始化
@ -335,6 +337,30 @@ public class GameLauncher : MonoBehaviour
_finalProgess = progress;
}
private void TrackHarmonyFirstStart()
{
#if UNITY_OPENHARMONY
var markerPath = Path.Combine(Application.persistentDataPath, "local_hm_first_start");
if (File.Exists(markerPath))
{
Debug.Log("BI AOT 鸿蒙首次启动事件已上报,跳过 hm_first_start");
return;
}
BIToolinAOT.Instance.TrackEventInAOT("hm_first_start", null);
try
{
File.WriteAllText(markerPath, DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString());
Debug.Log("BI AOT 鸿蒙首次启动事件标记写入成功: " + markerPath);
}
catch (Exception e)
{
Debug.LogError("BI AOT 鸿蒙首次启动事件标记写入失败: " + e);
}
#endif
}
#region iOS_DeviceHelper
#if UNITY_IOS && !UNITY_EDITOR