Dan*_*all 3 c# xamarin.ios xamarin xamarin.forms
每当我调用我的方法从Xamarin中的AccountStore中删除某些内容时,它会删除它并说该列表中的内容少了一些.首先从依赖服务调用以下方法.
public void DeleteSecureValue(string appName, string key)
{
var account = AccountStore.Create().FindAccountsForService(appName).FirstOrDefault();
if (account.Properties.ContainsKey(key))
account.Properties.Remove(key);
var props = account.Properties;
// when debugging, props doesn't contain a value for passcode
}
Run Code Online (Sandbox Code Playgroud)
Xamarin.Forms.DependencyService.Get<IStorageHandler>().DeleteSecureValue(GlobalConstants.APP_NAME, "passcode");
var account = AccountStore.Create().FindAccountsForService(GlobalConstants.APP_NAME).FirstOrDefault();
var props = account.Properties;
// when debugging, props now has a value for passcode when it shouldn't
Run Code Online (Sandbox Code Playgroud)
为什么密码的值似乎回来了?
你只是在内存中操纵一个字典DeleteSecureValue.您必须将更改写回存储.
public void DeleteSecureValue(string appName, string key)
{
var store = AccountStore.Create();
var account = AccountStore.Create().FindAccountsForService(appName).FirstOrDefault();
if (account.Properties.ContainsKey(key))
{
account.Properties.Remove(key);
store.Save(account, appName);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1280 次 |
| 最近记录: |