Facebook SDK for Unity Reference

This document provides the API details for the Facebook SDK for Unity.

The architecture follows, as much as possible within the constraints of the supported platforms, the design of the Javascript SDK. All functions implementing I/O operations are asynchronous and take a delegate as an argument which will be called with their output once it is ready.

Most data exchanged over the network is marshalled as strings containing JSON, and a utility class, Json, is provided to help manage that data within Unity.

Note: The Facebook SDK for Unity works with Unity 5.0 and above.

Core Methods

Name Description

FB.Init

Initialize the SDK, this is required before doing anything else

FB.API

Make an API call to the Graph API

FB.ShareLink

Trigger a Share dialog for one-to-many sharing

FB.FeedShare

Trigger the legacy Feed sharing dialog, only use if you need legacy parameters

FB.AppRequest

Trigger a Game Request dialog for one-to-one sharing

FB.GetAppLink

Get the URL with which the app was invoked

Facebook Login

Name Description

FB.LogInWithReadPermissions

Prompt a user to authorize your app with requested read permissions, or to grant additional read permissions

FB.LogInWithPublishPermissions

Prompt a user to authorize your app with publish permissions, or to grant additional permissions

FB.LogOut

Log a user entirely out of Facebook

Express Login

NameDescription

FB.Android.RetrieveLoginStatus

Retrieves the login status of the user.

Session Properties

Name Description

AccessToken

The access token granted to your application by the current user

FB.IsInitialized

Check whether the SDK has been initialized

FB.IsLoggedIn

Check whether a user is currently logged in and has authorized your app

FB.GraphApiVersion

Check whether a user is currently logged in and has authorized your app

App Events

Name Description

FB.ActivateApp

Signal an app launch or resume, for integrating with App Ads and Facebook Analytics for Apps

FB.LogAppEvent

Publish an App Event, for deeper integration with App Ads and Facebook Analytics for Apps

FB.LogPurchase

Convience method for publishing purchase events, for deeper integration with App Ads and Facebook Analytics for Apps

Mobile-only

Name Description

FB.Mobile.RefreshCurrentAccessToken

Updates the current access token with up-to-date permissions, and extends the expiration date if possible

FB.Mobile.AppInvite

Open an App Invite dialog, giving users the ability to send their friends a personal invite to your app

FB.Mobile.FetchDeferredAppLinkData

Fetch deferred applink data from App Ads or invites

FB.Mobile.ShareDialogMode

Set the preferred dialog type when using FB.ShareLink

Canvas-only Methods

Name Description

FB.Canvas.Pay

Prompt the user to make a payment using Facebook Payments

Auxiliary Methods

Name Description

FB.GameGroupCreate

Prompt user to create a new Game Group

FB.GameGroupJoin

Prompt user to join a Game Group

Other References

SDK Examples

Examples for the several common scenarios with the Facebook SDK for Unity

Using JSON with Unity

JSON is widely-used for data interchange; we can help you use it with Unity