![](/img/trans.png)
[英]Limitations of Background agents and cross-app access in Windows Phone 8.1
[英]Cross-App Keychain Access, where to configure?
我目前正在開發多個跨平台應用程序(在iOS下),這些應用程序使用一些共享的鑰匙串條目。 我目前的專案是從android開始的,在有了可用的版本后,我繼續在iOS版本上進行作業。 我從較早的項目中導入了鑰匙串訪問代碼,以訪問共享的登錄數據。 只有這次查詢總是返回SecStatusCode.ItemNotFound。
我比較了配置文件和權利,並且看起來都一樣。 一段時間后,我發瘋了,我創建了一個新的空應用程序,其中僅包含鑰匙串代碼,與當前不工作的應用程序相同的捆綁包標識符,配置文件和權利文件,並且可以正常工作並返回我的數據。
我的問題是,除了entitlements.plist和供應配置文件之外,還有什么地方需要配置,這可能會干擾我對鑰匙串條目的訪問? 由於項目更大,所以我不想將所有代碼復制到新項目中。 我嘗試了Windows的Visual Studio 2017和Mac 2019的VS。這是一個內部/企業應用程序,它引起任何關注...
鑰匙串通話:
KeyChain kc = new KeyChain("USER_DATA", "de.rlp.myCompany.Shared");
var data = kc.Find("LOGIN_DATA");
鑰匙扣級:
public class KeyChain
{
public string ServiceName { get; set; }
public string GroupName { get; set; }
public KeyChain(string serviceName, string groupName = null)
{
ServiceName = serviceName;
GroupName = groupName;
}
public byte[] Find(string key)
{
SecStatusCode res;
var rec = PrepareDictionary(key);
var match = SecKeyChain.QueryAsRecord(rec, out res);
if (res == SecStatusCode.Success) // ItemNotFound return-code here
{
return match.ValueData.ToArray();
}
else
{
System.Diagnostics.Debug.Write(res.ToString());
}
return null;
}
private SecRecord PrepareDictionary(string key)
{
var sr = new SecRecord(SecKind.GenericPassword)
{
Service = this.ServiceName,
Generic = NSData.FromString (key),
Account = key,
Accessible = SecAccessible.AlwaysThisDeviceOnly
};
if (string.IsNullOrEmpty(GroupName))
{
sr.AccessGroup = GroupName;
}
return sr;
}
}
權利入境
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)de.rlp.myCompany.Shared</string>
</array>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.