iOS SDK Version

FBSDKLoginManager

@interfaceFBSDKLoginManager:NSObject
FBSDKLoginManager provides methods for logging the user in and out.
FBSDKLoginManager serves to help manage sessions represented by tokens for authentication, AuthenticationToken, and data access, AccessToken.
You should check if the type of token you expect is present as a singleton instance, either AccessToken.current or AuthenticationToken.current before calling any of the login methods to see if there is a cached token available. A standard place to do this is in viewDidLoad.
Warning
If you are managing your own token instances outside of AccessToken.current, you will need to set AccessToken.current before calling any of the login methods to authorize further permissions on your tokens.
  • the default audience.
    you should set this if you intend to ask for publish permissions.

    Declaration

    Objective-C
    @property(nonatomic,assign,unsafe_unretained,readwrite)FBSDKDefaultAudiencedefaultAudience;
    Swift
    vardefaultAudience:DefaultAudience{getset}
  • Logs the user in or authorizes additional permissions.
    Use this method when asking for read permissions. You should only ask for permissions when they are needed and explain the value to the user. You can inspect the FBSDKLoginManagerLoginResultBlock‘s result.declinedPermissions to provide more information to the user if they decline permissions. You typically should check if AccessToken.current already contains the permissions you need before asking to reduce unnecessary login attempts. For example, you could perform that check in viewDidLoad.
    Warning
    You can only perform one login call at a time. Calling a login method before the completion handler is called on a previous login attempt will result in an error.
    Warning
    This method will present a UI to the user and thus should be called on the main thread.

    Declaration

    Objective-C
    -(void)logInWithPermissions:(nonnullNSArray<NSString*>*)permissionsfromViewController:(nullableUIViewController*)fromViewControllerhandler:(nullableFBSDKLoginManagerLoginResultBlock)handler;
    Swift
    funclogIn(permissions:[String],fromfromViewController:UIViewController?,handler:LoginManagerLoginResultBlock?=nil)

    Parameters

  • Logs the user in or authorizes additional permissions.
    Use this method when asking for permissions. You should only ask for permissions when they are needed and the value should be explained to the user. You can inspect the FBSDKLoginManagerLoginResultBlock‘s result.declinedPermissions to provide more information to the user if they decline permissions. To reduce unnecessary login attempts, you should typically check if AccessToken.current already contains the permissions you need. If it does, you probably do not need to call this method.
    Warning
    You can only perform one login call at a time. Calling a login method before the completion handler is called on a previous login attempt will result in an error.
    Warning
    This method will present a UI to the user and thus should be called on the main thread.

    Declaration

    Objective-C
    -(void)logInFromViewController:(nullableUIViewController*)viewControllerconfiguration:(nonnullFBSDKLoginConfiguration*)configurationcompletion:(nonnullFBSDKLoginManagerLoginResultBlock)completion;

    Parameters

  • Logs the user in with the given deep link url. Will only log user in if the given url contains valid login data.
    This method will present a UI to the user and thus should be called on the main thread. This method should be called with the url from the openURL method.
    Warning
    This method will present a UI to the user and thus should be called on the main thread.

    Declaration

    Objective-C
    -(void)logInWithURL:(nonnullNSURL*)urlhandler:(nullableFBSDKLoginManagerLoginResultBlock)handler;
    Swift
    funclogIn(url:URL,handler:LoginManagerLoginResultBlock?=nil)

    Parameters

  • Requests user’s permission to reathorize application’s data access, after it has expired due to inactivity.
    Use this method when you need to reathorize your app’s access to user data via the Graph API. You should only call this after access has expired. You should provide as much context to the user as possible as to why you need to reauthorize the access, the scope of access being reathorized, and what added value your app provides when the access is reathorized. You can inspect the result.declinedPermissions to determine if you should provide more information to the user based on any declined permissions.
    Warning
    This method will reauthorize using a LoginConfiguration with FBSDKLoginTracking set to .enabled.
    Warning
    This method will present UI the user. You typically should call this if AccessToken.isDataAccessExpired is true.

    Declaration

    Objective-C
    -(void)reauthorizeDataAccess:(nonnullUIViewController*)fromViewControllerhandler:(nonnullFBSDKLoginManagerLoginResultBlock)handler;
    Swift
    funcreauthorizeDataAccess(fromfromViewController:UIViewController,handler:@escapingLoginManagerLoginResultBlock)

    Parameters

  • Logs the user out
    This nils out the singleton instances of AccessTokenAuthenticationToken and Profle.
    Note
    This is only a client side logout. It will not log the user out of their Facebook account.

    Declaration

    Objective-C
    -(void)logOut;
    Swift
    funclogOut()
  • Initialize an instance of LoginManager.

    Declaration

    Swift
    convenienceinit(defaultAudience:DefaultAudience=.friends)

    Parameters

  • Logs the user in or authorizes additional permissions.
    Use this method when asking for permissions. You should only ask for permissions when they are needed and the value should be explained to the user. You can inspect the result’s declinedPermissions to also provide more information to the user if they decline permissions.
    This method will present a UI to the user. To reduce unnecessary app switching, you should typically check if AccessToken.current already contains the permissions you need. If it does, you probably do not need to call this method.
    You can only perform one login call at a time. Calling a login method before the completion handler is called on a previous login will result in an error.

    Declaration

    Swift
    funclogIn(permissions:[Permission]=[.publicProfile],viewController:UIViewController?=nil,completion:LoginResultBlock?=nil)

    Parameters

  • Logs the user in or authorizes additional permissions.
    Use this method when asking for permissions. You should only ask for permissions when they are needed and the value should be explained to the user. You can inspect the result’s declinedPermissions to also provide more information to the user if they decline permissions.
    This method will present a UI to the user. To reduce unnecessary app switching, you should typically check if AccessToken.current already contains the permissions you need. If it does, you probably do not need to call this method.
    You can only perform one login call at a time. Calling a login method before the completion handler is called on a previous login will result in an error.

    Declaration

    Swift
    funclogIn(viewController:UIViewController?=nil,configuration:LoginConfiguration,completion:@escapingLoginResultBlock)

    Parameters

  • Logs the user in or authorizes additional permissions.
    Use this method when asking for permissions. You should only ask for permissions when they are needed and the value should be explained to the user. You can inspect the result’s declinedPermissions to also provide more information to the user if they decline permissions.
    This method will present a UI to the user. To reduce unnecessary app switching, you should typically check if AccessToken.current already contains the permissions you need. If it does, you probably do not need to call this method.
    You can only perform one login call at a time. Calling a login method before the completion handler is called on a previous login will result in an error.

    Declaration

    Swift
    funclogIn(configuration:LoginConfiguration,completion:@escapingLoginResultBlock)

    Parameters