LoginManager class provides methods to perform Facebook Login operations programmatically, giving you full control over the login flow.
Import
Methods
logInWithPermissions
Logs in a user with the requested permissions.Parameters
Returns
Promise<LoginResult> - Resolves with a LoginResult object containing:
Example
iOS Limited Login Example
logOut
Logs out the currently logged-in user.Example
setLoginBehavior
Sets the login behavior for Android. iOS always uses browser-based login.Parameters
LoginBehaviorAndroid values:
'native_with_fallback'(default) - Attempt Facebook app login, fall back to web dialog'native_only'- Only use Facebook app for login'web_only'- Only use web dialog for login
Example
getLoginBehavior
Gets the current login behavior setting (Android only).Returns
Promise<LoginBehavior> - Resolves with the current login behavior:
- On Android: One of
LoginBehaviorAndroidvalues - On iOS: Always returns
'browser'
Example
setDefaultAudience
Sets the default audience for posts made by the application.Parameters
DefaultAudience values:
'friends'- Only friends can see posts'everyone'- All Facebook users can see posts'only_me'- Only the user can see posts
Example
getDefaultAudience
Gets the current default audience setting.Returns
Promise<DefaultAudience> - Resolves with the current default audience setting.
Example
reauthorizeDataAccess
Re-authorizes the user’s data access. Use this when data access permissions have expired.Returns
Promise<LoginResult> - Same as logInWithPermissions.
Example
Types
DefaultAudience
LoginBehavior
LoginBehaviorAndroid
native_with_fallback- Try Facebook app, fall back to web dialognative_only- Only use Facebook appweb_only- Only use web dialog
LoginBehaviorIOS
LoginResult
LoginTracking
'enabled'- Traditional login with full tracking (default)'limited'- Limited Login for privacy-focused authentication
Complete Usage Example
See Also
Login Methods
Learn about different login methods
Authentication
Understand access tokens and authentication
AccessToken
API reference for AccessToken
LoginButton
API reference for LoginButton component