小编vsf*_*tam的帖子

ACAccountStore accountsWithAccountType返回空列表,但授予访问请求

我有以下一段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)
    }
}
Run Code Online (Sandbox Code Playgroud)

requestAccessToAccountsWithType for Twitter(com.apple.twitter)被授予accountsWithAccountType返回0

ios acaccountstore swift

3
推荐指数
1
解决办法
1178
查看次数

标签 统计

acaccountstore ×1

ios ×1

swift ×1