Overview
Profile represents a cached, immutable snapshot of a Facebook user’s profile. The SDK fetches profile data from the Graph API /me endpoint and stores the result in UserDefaults. When the profile changes, the SDK posts a .profileDidChange notification so your UI can update.
You can configure the class to automatically refresh whenever AccessToken.current changes, which means you typically only need to call loadCurrentProfile(completion:) once, or rely on the auto-update behavior.
| Module | FacebookCore |
| Objective-C name | FBSDKProfile |
| Availability | iOS 12+ |
Static properties
The profile for the currently logged-in user.
nil if no user is logged in or the profile has not yet been loaded. Persisted to UserDefaults.standard between app launches.When
true, the SDK automatically fetches a new profile from the Graph API whenever AccessToken.current changes and the new token belongs to a different user.Instance properties
The Facebook user identifier.
The user’s first name.
The user’s middle name.
The user’s last name.
The user’s complete, formatted name.
A URL to the user’s Facebook profile page.
Only populated when the user has granted the
user_link permission.The date and time when this profile snapshot was last fetched from the Graph API.
A URL suitable for fetching the user’s profile picture. Use
imageURL(forMode:size:) to request a specific size and crop mode.The user’s email address.
Only populated when the user has granted the
email permission.A list of user IDs for the user’s friends who also use your app.
Only populated when the user has granted the
user_friends permission.The user’s birthday.
Only populated when the user has granted the
user_birthday permission.The user’s age range (e.g.,
min: 21). Useful when you need age verification but the user has not granted the user_birthday permission.Only populated when the user has granted the
user_age_range permission.The user’s hometown, as a
Location object containing an id and a name.Only populated when the user has granted the
user_hometown permission.The user’s current location, as a
Location object containing an id and a name.Only populated when the user has granted the
user_location permission.The user’s gender.
Only populated when the user has granted the
user_gender permission.The set of permissions the user has granted to your application.
Instance methods
imageURL(forMode:size:)
Returns a URL for fetching the user’s profile picture at a specific size and crop mode.
The crop mode for the image. One of:
| Value | Description |
|---|---|
.square | Crops the image to a square. |
.normal | Preserves the original aspect ratio. |
.album | Preserves the original aspect ratio (album-style). |
.small | Preserves the original aspect ratio (small). |
.large | Preserves the original aspect ratio (large). |
The desired width and height in points. Values are rounded to the nearest integer.
nil if the SDK cannot construct one (e.g., no access token or client token is set).
Static methods
loadCurrentProfile(completion:)
Loads the profile for the current access token and updates Profile.current. If a non-expired profile is already cached for the same user, the completion block is called synchronously with the cached value.
A closure called when loading completes. Receives an optional
Profile and an optional Error. Both values can be nil if the profile changed mid-flight.Notifications
| Name | Description |
|---|---|
Notification.Name.profileDidChange | Posted on the default NotificationCenter when Profile.current changes. |