iOS: Check if user is already logged in using Facebook?

hutututu picture hutututu · May 13, 2015 · Viewed 14.1k times · Source

I have started working on an iOS app on Xcode using Swift and storyboards. I have a requirement where on click of a button I will show a user's Facebook profile info on the screen (only if user is signed in using Facebook), but if he is not signed in it will automatically go to login screen and on successful login again the profile view will be shown.

How can I do this?

Answer

chedabob picture chedabob · May 13, 2015

If you're using the Facebook Login SDK, call

FBSDKAccessToken.currentAccessToken()

It will be not nil if the user is logged in.

https://developers.facebook.com/docs/facebook-login/ios/v2.3#token