There is no more class FBSession
in new Facebook iOS SDK v4.x. How can I find out whether user is logged in or not now? Thanks in advance.
In Xcode, click File > Swift Packages > Add Package Dependency. In the dialog that appears, enter the repository URL: https://github.com/facebook/facebook-ios-sdk. In Version, select Up to Next Major and the default option. Complete the prompts to select the libraries you want to use in your project.
Step 1: Configure Your Facebook AppNavigate to Settings > Basic to view the App Details Panel with your App ID, your App Secret, and other details about your app. Scroll down to the bottom of page, and click Add Platform. Choose iOS, add your app details, and save your changes.
The Facebook SDK is what allows mobile app developers to integrate Facebook within a mobile app. SDK stands for software development kit, and it allows for a website or app to integrate with Facebook seamlessly.
Vincent is right, check [FBSDKAccessToken currentAccessToken] to determine if the user is logged in.
To check if the user logged in and if so, navigate to another view:
if ([FBSDKAccessToken currentAccessToken]) {
// User is logged in
[self performSelector:@selector(accessGrantedNavigation)
withObject:nil afterDelay:0.0];
}
-(void)accessGrantedNavigation{
[self performSegueWithIdentifier: @"segueLoginFB" sender: self];
}
To log out: (although it doesn't allow to change FB user. I think it is because Safari already takes care of that session and remains the same user.)
FBSDKLoginManager *manager = [[FBSDKLoginManager alloc] init];
[manager logOut];
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With