我正在开发一个使用 Parse 和 Facebook 的 iOS 应用程序。
对于 Facebook 登录,我遵循此页面上的指南:https ://www.parse.com/tutorials/integrating-facebook-in-ios
按照指南,我有这段代码可以验证缓存的会话:
// check if this cached session is still valid?
// does nothing if still valid
- (void) validateCachedSession
{
FBRequest *request = [FBRequest requestForMe];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error)
{
// handle successful response
LogObvious(@"Facebook session validated. No problem");
}
else if ([error.userInfo[FBErrorParsedJSONResponseKey][@"body"][@"error"][@"type"] isEqualToString:@"OAuthException"])
{ // Since the request failed, we can check if it was due to an invalid session
LogObvious(@"The facebook session was invalidated. Announce logged Out");
// The persisted session is invalid. Logout!
[self logout];
}
else
{
LogObvious(@"The facebook session was invalidated. Announce logged Out");
// The persisted session is invalid. Logout!
[self logout];
}
}];
}
如上图,如果缓存的session无效,应该调用logout:
- (void) logout
{
[PFUser logOut];
// Over here we will show the login button again.
}
为了测试这个。我首先使用 Facebook 帐户登录我的应用程序。然后,我更改了密码并重新访问该应用程序。
应用程序正确识别会话无效并调用注销。
但是当我再次单击登录时,登录功能返回此错误:
Uh oh. An error occurred: Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x1e066140 {com.facebook.sdk:ErrorInnerErrorKey=Error Domain=com.apple.accounts Code=1 "Server refused renewal request with error code: 190" UserInfo=0x1d56df10 {NSLocalizedDescription=Server refused renewal request with error code: 190}, com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 190;
"error_subcode" = 65001;
};
};
}}
为什么?即使我终止应用程序并重新启动它。该应用程序现在将停留在此状态 - 无法登录。任何帮助将不胜感激。
p / s:要清楚,这是我的登录功能:
// to be called when user explicitly clicked a login button
- (void) loginByFacebookWithPermissions:(NSArray*)permissionsArray
{
LogFunctionCalledObvious();
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error)
{
if (!user)
{
if (!error)
{
NSLog(@"Uh oh. The user cancelled the Facebook login.");
} else
{
NSLog(@"Uh oh. An error occurred: %@", error);
[self logout];
}
} else if (user.isNew)
{
LogObvious(@"User with facebook signed up and logged in!");
[self requestLoggedInUserInfo];
} else
{
LogObvious(@"User with facebook logged in!");
[self requestLoggedInUserInfo];
}
}];
}
p/s2:好的,经过更多调查,所以它一直停留在这种状态,直到我转到设置-> Facebook 重新输入新密码。这是正确的行为吗?当我从 Facebook.com 更改 Facebook 密码时,iOS6 不应该及时提醒用户更改密码吗?