下面有一段Swift代码可以连接到我的iOS模拟器中的twitter帐户。
我对requestAccessToAccountsWithType的调用被授予,但是ACAccountStore.accountsWithAccountType返回一个空列表。
我遗漏了什么?
let accountStore = ACAccountStore()
let twitterAccountType = accountStore.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierTwitter)
accountStore.requestAccessToAccountsWithType(twitterAccountType, options: nil) { (granted, error) in
if granted {
print("requestAccessToAccountsWithType for \(twitterAccountType) is granted\n")
let accounts = accountStore.accountsWithAccountType(twitterAccountType)
print("accountsWithAccountType returns \(accounts.count) ")
} else {
let error = "Access to Twitter was not granted."
self.log(error)
handler(error)
}
}requestAccessToAccountsWithType for Twitter (com.apple.twitter)被授予accountsWithAccountType返回0
发布于 2015-04-19 22:25:40
授予访问权限是一回事,您还需要在设备/模拟器上配置Twitter帐户。检查你是否设立了任何帐户。
https://stackoverflow.com/questions/29721496
复制相似问题