我已经登录了设备设置,然后我正在访问我的 Facebook 功能,它没有加载相册,它的返回会话状态为 513 ,并且在尝试获取相册时它返回 190 错误代码。190 表示“无效的 OAuth 2.0 访问令牌”。
如果我从设备设置中删除该帐户并且如果我再次登录,那么它工作正常。如果我已经登录设备设置,我只会在第一次安装应用程序时遇到这个问题。可能是什么原因?谁可以帮我这个事?请在下面找到我写的代码..
/*
* Opens a Facebook session and optionally shows the login UX.
*/
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI WithSuccessBlock:(FacebookAuthSuccessBlock)fbSuccessBlock andFailureBlock:(FacebookAuthFailureBlock)fbFailureBlock
{
BOOL result = NO;
[FBSession.activeSession closeAndClearTokenInformation];
if (fbSuccessBlock != nil)
{
fbAuthSuccessBlock = fbSuccessBlock;
}
if (fbFailureBlock != nil)
{
fbAuthFailureBlock = fbFailureBlock;
}
NSArray *permissions = [[NSArray alloc] initWithObjects:
USER_PHOTOS,
READ_STREAM,
FRIENDS_PHOTOS,
nil];
FBSession *session = [[FBSession alloc] initWithAppID:FB_APP_ID permissions:permissions
urlSchemeSuffix:@"Sample"
tokenCacheStrategy:nil];
if (allowLoginUI ||
(session.state == FBSessionStateCreatedTokenLoaded))
{
[FBSession setActiveSession:session];
[session openWithBehavior:FBSessionLoginBehaviorUseSystemAccountIfPresent
completionHandler:
^(FBSession *session, FBSessionState state, NSError *error)
{
[self sessionStateChanged:session state:state error:error];
}];
result = session.isOpen;
}
return result;
}
//////
//Facebook Settings
/*
* Callback for session changes.
*/
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState) state
error:(NSError *)error
{
dispatch_async(dispatch_get_main_queue(), ^{
FRMLogInfo(@"*******state = %d*********", state);
switch (state) {
case FBSessionStateOpen:
if (!error)
{
// We have a valid session
fbAuthSuccessBlock();
}
break;
case FBSessionStateClosed:
[FBSession.activeSession closeAndClearTokenInformation];
break;
case 2:
case FBSessionStateClosedLoginFailed:
{
if (fbAuthFailureBlock)
{
fbAuthFailureBlock();
}
}
break;
default:
FRMLogInfo(@"Some thing else.....");
break;
}
[[NSNotificationCenter defaultCenter]
postNotificationName:FBSessionStateChangedNotification
object:session];
if (error)
{
FRMLogInfo(@"error:%@",[error localizedDescription]);
[BlockAlertView multiButtonAlert:NSLocalizedStringFromTableInBundle(@"FB_ERROR_TITLE", nil, [[LocalizationHelper sharedLocalizationHelper] localizationBundle], @"")
message:NSLocalizedStringFromTableInBundle(@"FB_ERROR_MSG", nil, [[LocalizationHelper sharedLocalizationHelper] localizationBundle], @"")
style:UIAlertViewStyleDefault
cancelTitle:@"OK"
cancelBlock:^{
}
otherTitle:nil
otherBlocks:nil];
}
});
}