2017年7月20日 | Leave a comment 问题: ios 使用Accounts.framework 怎么实现facebook登录 官方framework文档没有找到 指南,只有参考 解决: @IBAction func onLoginButtonTap(_ sender: Any) { let store = ACAccountStore() let type = store.accountType(withAccountTypeIdentifier: ACAccountTypeIdentifierFacebook) store.requestAccessToAccounts(with: type, options: [ACFacebookAppIdKey:"796207910547868", ACFacebookPermissionsKey:["email"] ]) { (ok, error) in print("\(ok)\t \(error)") if ok { if let accounts = store.accounts(with: type) {//有账号 guard accounts.count > 0 else { print("无账号"); return } for a in accounts { print("\(a)\n"); } }else { print("登录失败") } } else { print("未找到授权账号") } } } 12345678910111213141516171819 @IBAction func onLoginButtonTap(_ sender: Any) { let store = ACAccountStore() let type = store.accountType(withAccountTypeIdentifier: ACAccountTypeIdentifierFacebook) store.requestAccessToAccounts(with: type, options: [ACFacebookAppIdKey:"796207910547868", ACFacebookPermissionsKey:["email"] ]) { (ok, error) in print("\(ok)\t \(error)") if ok { if let accounts = store.accounts(with: type) {//有账号 guard accounts.count > 0 else { print("无账号"); return } for a in accounts { print("\(a)\n"); } }else { print("登录失败") } } else { print("未找到授权账号") } } } 参考: http://blog.sina.com.cn/s/blog_916e0cff0101gdns.html http://www.itstrike.cn/Question/f5754700-3698-408b-a3b8-d05fbdc4da44.html https://stackoverflow.com/questions/12630066/acaccountstore-error-6-acerroraccountnotfound-and-8