I already logged in device settings and then i am accessing my Facebook feature its not loading albums, its returning session state as 513 , and while trying to get albums its returning 190 error code. 190 indicates "Invalid OAuth 2.0 Access Token".
If i delete the account from device setting and if i again logging in, then its working fine. I am facing this issue only very first time installation of app that too if i already logged in device setting.What could be the reason? can any one help me on this? Please find below code ..that i have written ..
/*
* 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];
}
});
}