Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No FBSession in Facebook iOS SDK 4.x

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.

like image 734
demon9733 Avatar asked Mar 26 '15 15:03

demon9733


People also ask

How initialize Facebook SDK iOS?

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.

How do I add iOS to Facebook?

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.

What is Facebook SDK for iOS?

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.


2 Answers

Vincent is right, check [FBSDKAccessToken currentAccessToken] to determine if the user is logged in.

like image 89
Chris Pan Avatar answered Oct 05 '22 19:10

Chris Pan


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.

like image 25
MLBDG Avatar answered Oct 05 '22 18:10

MLBDG