我想知道 Apple 是否会拒绝此解决方案以获取 Xamarin iOS 中的唯一 ID?
public string GetIdentifier()
{
enter code here`var query = new SecRecord(SecKind.GenericPassword);
query.Service = NSBundle.MainBundle.BundleIdentifier;
query.Account = "UniqueID";
NSData uniqueId = SecKeyChain.QueryAsData(query);
if (uniqueId == null)
{
query.ValueData = NSData.FromString(System.Guid.NewGuid().ToString());
var err = SecKeyChain.Add(query);
if (err != SecStatusCode.Success && err != SecStatusCode.DuplicateItem)
throw new Exception("Cannot store Unique ID");
return query.ValueData.ToString();
}
else
{
return uniqueId.ToString();
}
}