我有以下 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)
}
}
Twitter (com.apple.twitter) 的 requestAccessToAccountsWithType 被授予 accountsWithAccountType 返回 0