ACAccountStore accountsWithAccountType returning empty list but access request is granted

I have the following Swift code to connect to Twitter account in my iOS simulator.

My call is requestAccessToAccountsWithType

provided, but it 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) provided by accountsWithAccountType returns 0

+3


source to share


1 answer


Granting access is one thing, you will also need to have a Twitter account set up on the device / simulator. Check if any accounts are set up.



+5


source







All Articles