From 0cda299cf3d83e985c9b79e45835faafcc9d04a4 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 17 Nov 2015 19:08:42 +0700 Subject: [PATCH] fix bug call function isLoggedIn in facebookAgent return wrong result --- .../proj.ios/PluginFacebook/UserFacebook.m | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/facebook/proj.ios/PluginFacebook/UserFacebook.m b/plugins/facebook/proj.ios/PluginFacebook/UserFacebook.m index f1b7767c..8e909678 100644 --- a/plugins/facebook/proj.ios/PluginFacebook/UserFacebook.m +++ b/plugins/facebook/proj.ios/PluginFacebook/UserFacebook.m @@ -37,6 +37,20 @@ @implementation UserFacebook NSString *_userId = @""; NSString *_accessToken = @""; +- (id) init { + if (self = [super init]) { + if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) { + // Even though we had a cached token, we need to login to make the session usable: + [FBSession.activeSession openWithCompletionHandler:^(FBSession *session, FBSessionState state, NSError *error) { + [self sessionStateChanged:session state:state error:error]; + }]; + } + return self; + } + else + return nil; +} + - (void) configDeveloperInfo : (NSMutableDictionary*) cpInfo{ } - (void) login{ @@ -67,13 +81,13 @@ - (void) logout{ } } - (BOOL) isLogined{ - return _isLogin; + return FBSession.activeSession.state == FBSessionStateOpen || FBSessionStateOpen == FBSessionStateOpenTokenExtended; } -(NSString *)getUserID{ return _userId; } - (BOOL) isLoggedIn{ - return _isLogin; + return [self isLogined]; } -(NSString *) getPermissionList{