I have the following piece of Swift code to connect to twitter account in my iOS simulator.
My call to requestAccessToAccountsWithType
is granted, but the ACAccountStore.accountsWithAccountType
returns an empty list.
What am I missing?
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) is granted accountsWithAccountType returns 0
Granting access is one thing, you would also need to have a Twitter account configured on the device/simulator. Check if you have any accounts set up.