好的,我终于找到了有关它的信息。考虑这种情况:我们的应用程序已经被用户授权,并且我们已经获得了访问令牌和秘密。现在我们要支持新的 iOS 6 功能并在设置中创建 twitter(例如)帐户。为此,我们需要将这些令牌迁移到中央帐户存储。就是这样:
- (void)storeAccountWithAccessToken:(NSString *)token secret:(NSString *)secret {
//We start creating an account by creating the credentials object
ACAccountCredential *credential = [[ACAccountCredential alloc] initWithOAuthToken:token tokenSecret:secret];
ACAccountType *twitterAcctType =[self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
ACAccount *newAccount = [[ACAccount alloc] initWithAccountType:twitterAcctType];
//Here we assign credentials and now can save account
newAccount.credential = credential;
[self.accountStore saveAccount:newAccount withCompletionHandler:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"the account was saved!");
}
else {
//Handle error here
}
}];
}
有关它的更多信息,请在此处阅读如何迁移令牌