API
initialize(...)login(...)logout()reauthorize()getCurrentAccessToken()getProfile(...)logEvent(...)setAutoLogAppEventsEnabled(...)setAdvertiserTrackingEnabled(...)setAdvertiserIDCollectionEnabled(...)- Interfaces
- Type Aliases
method initialize(...)
initialize(options: Partial<FacebookConfiguration>) => Promise<void>
Initializes the Facebook JavaScript SDK on Web.
This is a no-op on Android and iOS, where the SDK is configured natively.
| Param | Type |
|---|---|
options |
Partial<FacebookConfiguration> |
method login(...)
login(options: { permissions: string[]; tracking?: 'limited' | 'enabled'; nonce?: string; }) => Promise<FacebookLoginResponse>
Starts the Facebook login flow with the requested permissions.
A cancelled native login resolves without a token.
| Param | Type |
|---|---|
options |
{ permissions: string[]; tracking?: 'limited' \| 'enabled'; nonce?: string; } |
Returns: Promise<FacebookLoginResponse>
method logout()
logout() => Promise<void>
Logs out the current Facebook session.
method reauthorize()
reauthorize() => Promise<FacebookLoginResponse>
Requests renewed data access for the current Facebook session.
Returns: Promise<FacebookLoginResponse>
method getCurrentAccessToken()
getCurrentAccessToken() => Promise<FacebookCurrentAccessTokenResponse>
Returns the current token. iOS returns an OIDC authentication token for
Limited Login. Native platforms resolve without a token when logged out;
Web rejects when there is no connected Facebook session.
Returns: Promise<FacebookCurrentAccessTokenResponse>
method getProfile(...)
getProfile<T extends Record<string, unknown>>(options: { fields: readonly string[]; }) => Promise<T>
Requests the selected fields from the Facebook Graph API /me endpoint.
| Param | Type |
|---|---|
options |
{ fields: readonly string[]; } |
Returns: Promise<T>
method logEvent(...)
logEvent(options: { eventName: string; parameters?: Record<string, string | number>; }) => Promise<void>
Logs a Facebook App Event with optional string or number parameters.
| Param | Type |
|---|---|
options |
{ eventName: string; parameters?: Record<string, string \| number>; } |
method setAutoLogAppEventsEnabled(...)
setAutoLogAppEventsEnabled(options: { enabled: boolean; }) => Promise<void>
Enables or disables automatic App Event logging on native platforms.
| Param | Type |
|---|---|
options |
{ enabled: boolean; } |
method setAdvertiserTrackingEnabled(...)
setAdvertiserTrackingEnabled(options: { enabled: boolean; }) => Promise<void>
Enables or disables advertiser tracking on iOS.
| Param | Type |
|---|---|
options |
{ enabled: boolean; } |
method setAdvertiserIDCollectionEnabled(...)
setAdvertiserIDCollectionEnabled(options: { enabled: boolean; }) => Promise<void>
Enables or disables advertiser ID collection on native platforms.
| Param | Type |
|---|---|
options |
{ enabled: boolean; } |
Interfaces
interface FacebookConfiguration
| Prop | Type | Description |
|---|---|---|
appId |
string |
Meta application ID. |
autoLogAppEvents |
boolean |
Whether the Web SDK automatically logs App Events. |
xfbml |
boolean |
Whether the Web SDK parses XFBML social plugins. |
version |
string |
Facebook Graph API version used by the Web SDK. Defaults to v26.0. |
locale |
string |
Locale used to load the Web SDK. Defaults to en_US. |
interface FacebookLoginResponse
| Prop | Type | Description |
|---|---|---|
accessToken |
AccessToken \| null |
Token response when one is returned by the platform. |
recentlyGrantedPermissions |
string[] |
Permissions granted during this login. |
recentlyDeniedPermissions |
string[] |
Permissions denied during this login. |
interface AccessToken
| Prop | Type | Description |
|---|---|---|
applicationId |
string |
Meta application ID that issued the token. |
declinedPermissions |
string[] |
Permissions declined by the user. |
expires |
string |
ISO 8601 token expiration date. |
isExpired |
boolean |
Whether the token is expired. |
lastRefresh |
string |
ISO 8601 date when the token was last refreshed. |
permissions |
string[] |
Permissions granted to the token. |
token |
string |
Token string returned by the platform. With iOS Limited Login, this is an OIDC authentication token (JWT), not a Graph API access token. |
userId |
string |
Facebook user ID associated with the token. |
interface FacebookCurrentAccessTokenResponse
| Prop | Type | Description |
|---|---|---|
accessToken |
AccessToken \| null |
Current token response when one is returned by the platform. |
Type Aliases
type alias Partial
Make all properties in T optional
{
[P in keyof T]?: T[P];
}
type alias Record
Construct a type with a set of properties K of type T
{
[P in K]: T;
}