Documentation Index
Fetch the complete documentation index at: https://mintlify.com/facebook/facebook-ios-sdk/llms.txt
Use this file to discover all available pages before exploring further.
LoginManager is the primary class for triggering the Facebook Login flow. It handles browser or native app switching, the OAuth callback, token storage, and logout. You interact with it directly when you want full control over when and how the login UI appears.
Instantiate LoginManager
defaultAudience property controls the initial audience for posts made through your app. The available values are:
| Value | Description |
|---|---|
.friends | The user’s friends can see posts (default) |
.onlyMe | Only the user can see posts |
.everyone | All Facebook users can see posts |
Check for a cached token first
Before callinglogIn, check whether the user is already authenticated. Doing this in viewDidLoad avoids an unnecessary login prompt:
Log in with a configuration
Build aLoginConfiguration with the permissions you need, then call logIn(viewController:configuration:completion:):
Pass
nil for viewController and the SDK will determine the topmost view controller automatically.Handle the LoginResult
The completion block receives aLoginResult, which is a Swift enum with three cases:
granted and declined sets reflect only the permissions affected in this login request, not the full historical set. Check AccessToken.current?.permissions for the complete granted set.
Log out
CalllogOut() to clear the cached AccessToken, AuthenticationToken, and Profile:
This is a client-side logout only. It does not revoke the token on Facebook’s servers or log the user out of the Facebook app.
Reauthorize data access
Facebook periodically expires data access for inactive users. WhenAccessToken.isDataAccessExpired is true, call reauthorizeDataAccess(from:handler:) to restore it without asking for new permissions:
Request additional permissions
If a feature in your app needs permissions you did not request at login, calllogIn again with the new permissions. The SDK shows the Facebook dialog only for the permissions not yet granted: