我正在使用Swift 3在iOS 10上编写应用程序。当用户拒绝从系统中授权或未配置帐户(例如,“无法使用系统帐户进行身份验证”)时,sharedInstance()
方法会将错误抛出到控制台。在进入闭包之前,错误会显示在控制台上。我不想在应用程序中向用户显示这些错误,例如在警报中。以下是我的代码:
Twitter.sharedInstance().logIn { (session, error) in
if error != nil {
// print(error?.localizedDescription ?? " ")
return
})
我遇到了这个错误:
2016-11-29 14:49:09.023 CarReview[1254:31719] [TwitterKit] did encounter error with message "Unable to authenticate using the system account.": Error Domain=TWTRLogInErrorDomain Code=2 "User allowed permission to system accounts but there were none set up." UserInfo={NSLocalizedDescription=User allowed permission to system accounts but there were none set up.}
2016-11-29 14:49:09.024 CarReview[1254:31719] [TwitterKit] No matching scheme found.
2016-11-29 14:49:09.292 CarReview[1254:31719] [TwitterKit] did encounter error with message "Error obtaining user auth token.": Error Domain=TWTRLogInErrorDomain Code=-1 "<?xml version="1.0" encoding="UTF-8"?>
<hash>
<error>Desktop applications only support the oauth_callback value 'oob'</error>
<request>/oauth/request_token</request>
</hash>
" UserInfo={NSLocalizedDescription=<?xml version="1.0" encoding="UTF-8"?>
<hash>
<error>Desktop applications only support the oauth_callback value 'oob'</error>
<request>/oauth/request_token</request>
</hash>
}
我希望向用户展示以下信息:
"无法使用系统帐户进行身份验证。用户被允许使用系统帐户权限,但没有设置任何系统帐户。"