Gaming Services JavaScript SDK

This Facebook SDK (JS) App Events API has been deprecated and is no longer supported as of July 1, 2022. There are no plans to add new features to this product. Instead of using FB.AppEvents.LogEvent, we recommend that you send these events through the Meta Pixel.

Gaming Services is available as a new component in the official Facebook SDK for JavaScript. Using Facebook official SDKs is the recommended approach and makes it easy to access services enabled by Facebook Login for Gaming including the Player Finder and Sharing (for Gaming) experiences.

Prerequisites

  1. Your application needs to enroll in Gaming Services to access features in this document. Follow the instructions to enroll your application.
  2. Your application should be consuming the JS SDK from Facebook's CDN.

Implementation

Facebook Login for Gaming

Facebook Login for Gaming enable a new login method for games. It supports the same implementation and SDK methods as Facebook Login. If this is the first time you're integrating the Facebook SDK into your App, refer to the configuration guide before proceeding.

Instead of receiving public_profile, your application will receive gaming_profile as the default permission. Other requestable permissions include user_friends, email, and gaming_user_picture.


Gaming Graph Domain

After integrating with Facebook Login for Gaming, your application will receive an access token for use on Gaming graph domain (graph.fb.gg), instead of the Facebook graph domain (graph.facebook.com). Read more about gaming graph domain.

You can check if the current User has connected with Facebook Login For Gaming by verifying the Graph Domain to be gaming in the Access Token:

// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.
...
using Facebook.Unity;
...
AccessToken currentAccessToken = AccessToken.CurrentAccessToken;
if (currentAccessToken != null && currentAccessToken.GraphDomain == "gaming") {
  // current user has been migrated to Facebook Login for Gaming
}

Player Finder and Sharing (for Gaming)

Below is a Unity3D sample code showing how to implement Player Finder and Sharing (for Gaming).

      // opening the Player Finder Dialog.
      FB.gamingservices.friendFinder(function(response){
      	// this gets called when the dialog is closed.
      })
      
      // upload a Picture to the media library.
      FB.gamingservices.uploadImageToMediaLibrary(
      	"https://some/image.png",
        "caption",
        true, // if true will open the Media Dialog to share immediately
        function(response) { 
      		// this callback gets called when the upload is complete,
      		// or when the media dialog is closed (if shouldOpenMediaDialog was set to true)
      		console.log(response);
      });