Swift:处理Facebook令牌错误

时间:2017-02-04 23:10:51

标签: ios swift facebook-sdk-4.0

我正在尝试处理Facebook令牌无效时的事件。例如,当用户更改Facebook密码时。当我使用时:

FBSDKAccessToken.refreshCurrentAccessToken

并且用户更改密码,我会得到

Error validating access token: The session has been invalidated because the user has changed the password.

错误如下所示:

com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body =     {
    error =         {
        code = 190;
        "error_subcode" = 460;
        "fbtrace_id" = HFdKjQiGR0m;
        message = "Error validating access token: The session has been invalidated because the user has changed the password.";
        type = OAuthException;
    };
};
code = 400;
}, NSLocalizedRecoveryOptions=(
    OK,
    Cancel
)}

如何验证这些错误代码,以便我采取适当的措施?

1 个答案:

答案 0 :(得分:0)

查看包含完成处理程序类型(CommonDataKinds.Phone.NUMBER)的FBSDKGraphRequestConnection.h。此完成处理程序为您提供结果和错误,您可以解析该消息以获取消息,然后执行您需要的操作。