namespace XmobiTea.MiniDeviceId
{
using System;
using UnityEngine;
[Serializable]
public class CustomId
{
// Native plugin JSON payload shape: {"userId":"...","uuid":"..."}
[SerializeField]
public string userId;
[SerializeField]
public string uuid;
}
///
/// Apple-family implementation that persists the identifier through the native keychain bridge.
/// This asmdef is compiled for iOS, macOSStandalone, and tvOS in this package.
/// The repo ships native bridge source files under Plugins/iOS for iOS and tvOS imports.
///
public class Implement
{
private static readonly string UserSlotId = "0";
///
/// Returns the persisted keychain UUID when available.
/// If the keychain entry is empty, falls back to SystemInfo.deviceUniqueIdentifier,
/// then saves that value into the native keychain store.
///
public static string Get()
{
var customId = JsonUtility.FromJson(CXKeyChain.BindGetKeyChainUser());
var deviceId = customId.uuid;
if (string.IsNullOrEmpty(deviceId))
{
deviceId = SystemInfo.deviceUniqueIdentifier;
CXKeyChain.BindSetKeyChainUser(UserSlotId, deviceId);
Debug.Log("===Saved uuid on empty: [" + deviceId + "]");
}
return deviceId;
}
}
}