I'm using Xcode 6 & Facebook iOS SDK 4.3, I embedded the code, according to Facebook's guide and the login works, BUT from some reason -
after I login, the button doesn't change to "Log out", and stays "Log in with Facebook".
did anyone encounter this problem?
so I started all over, and followed the instructions from the guide :
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 after that didn't work, I've found this thread that mentioned I also need to add few things to the AppDelegate 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 had the Log in button changed to Log out !
I was experiencing the same issue, and couldn't find the answer anywhere. Turns out it was a Simulator problem; once I ran the same code on the device (iOS 9.3.1) everything worked out fine.
请记住启用钥匙串共享功能
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.