Ios Facebook login button - does not change for logout
I am using Xcode 6 and Facebook iOS SDK 4.3, I have embedded the code as per Facebook manual and login works, BUT for some reason -
after logging in, the button does not change to Log Out and remains Log in to Facebook.
Has anyone faced this problem?
+3
source to share
3 answers
so I started all over again and following the instructions from the manual :
1.in the viewController.h file :
#import < FBSDKCoreKit/FBSDKCoreKit.h> //<-delete the space
#import < FBSDKLoginKit/FBSDKLoginKit.h>//<-delete the space
@interface ViewController : UIViewController<FBSDKLoginButtonDelegate>
@property (weak, nonatomic) IBOutlet FBSDKLoginButton *loginButton;
2.in the viewController.m file :
-(void) viewDidLoad{
if ([FBSDKAccessToken currentAccessToken]) {
// User is logged in, do work such as go to next view controller.
}
self.loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
[self.view addSubview:loginButton];
}
and it didn't work after that, I found this thread which mentioned that I also need to add a few things to AppDelegate's didFinishLaunchingWithOptions :
return [[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
and
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
and then it worked! Finally, I clicked the Log In button on Log Out !
+6
source to share