SSKeychain:帐户未存储在iCloud中吗? [英] SSKeychain: Accounts not stored in iCloud?

查看:187
本文介绍了SSKeychain:帐户未存储在iCloud中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用sskeychain( https://github.com/soffes/sskeychain )存储我在IOS钥匙串中的帐户和密码.我假设,如果我存储一个帐户,则该帐户应该可以在其他设备上使用.但是它没有出现在这里.

I'm using sskeychain (https://github.com/soffes/sskeychain) to store my accounts and passwords in the IOS keychain. I assume, that if I store an account, it should be available on my other device. But it doesn't appear there.

我用以下代码读取了我的帐户:

I read my accounts with this code:

NSArray *arr=[SSKeychain accountsForService:@"Login"];
for (NSString *s in arr) {
    NSLog(@"Account: %@",s);
}

并获得此信息(仅显示一个条目,其他条目相似):

and get this (only shown one entry, the others are similar):

Account: {
acct = "friXXXXXter@XXXX.com";
agrp = "3B4384Z34A.de.gondomir.LocalButler";
cdat = "2014-05-09 22:55:08 +0000";
mdat = "2014-05-09 22:55:08 +0000";
pdmn = ak;
svce = Login;
sync = 0;
tomb = 0;
}

但是这不会出现在其他设备上.两种设备都具有IOS 7.1.1. 我在此行存储密码:

But this doesn't appear on the other device. Both devices have IOS 7.1.1. I store the password with this line:

  [SSKeychain setPassword:self.passwortField.text forService:@"Login" account:self.userField.text];

我已在Xcode中打开了钥匙串共享,并在其中列出了一个钥匙串组"de.gondomir.LocalButler".

I have switched on keychain sharing in Xcode and have a keychain group "de.gondomir.LocalButler" listed there.

我错过了什么吗?服务名称必须特别吗?

Am I missing something? Must the service name something special?

谢谢!

推荐答案

如果这仍然与您有关,我设法找到了解决方案. (适用于> = iOS7)

In case this is still relevant for you I managed to find the solution. (works for >=iOS7)

请勿使用SSKeychain的静态方法来编写您的凭据.而是使用SSKeychainQuery并像这样将syncingMode设置为SSKeychainQuerySynchronizationModeYes

Don't use the static methods of SSKeychain to write your credentials. Instead use SSKeychainQuery and set the synchronizationMode to SSKeychainQuerySynchronizationModeYes like this

NSError *error; 
[SSKeychain setAccessibilityType:self.keychainAccessibilityType];
SSKeychainQuery *query = [[SSKeychainQuery alloc] init];
query.service = service;
query.account = account;
query.password = password;
query.synchronizationMode = SSKeychainQuerySynchronizationModeYes;
[query save:&error];
if (error) {
    NSLog(@"Error writing credentials %@", [error description]);
}

SSKeychain上的静态便捷方法使用默认的同步模式SSKeychainQuerySynchronizationModeAny,导致凭据不与iCloud钥匙串同步.

The static convenience methods on SSKeychain use the default synchronization mode SSKeychainQuerySynchronizationModeAny causing credentials not to be synchronized with the iCloud keychain.

此外,请确保您的设备已启用通过iCloud的钥匙串(设置> iCloud>钥匙串).您可能还希望在目标功能中启用Keychain Sharing.

Additionally, make sure your devices have Keychain via iCloud enabled (Settings>iCloud>Keychain). You might also want to enable Keychain Sharing in your targets Capabilities.

这篇关于SSKeychain:帐户未存储在iCloud中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆