Skip to main content

Android

The purpose of this article is to describe how to set up Facebook authentication so that your game can be logged in through the Facebook channel using the Player Network login authentication service.

Prerequisites

1. Configure the app on the Facebook Developer platform
1. Register an Account

Before configuring the platform for your app, sign up for a Facebook developer account and create an app in the Facebook App Dashboard.

  1. Register for an account at Facebook and follow the prompts to complete account verification (Email or cell phone verification).

  2. Activate a developer account at Meta for Developers.

    Image: Activate a Facebook developer account

  3. Agree to the agreement and continue.

    Image: Consent to the agreement and continue

  4. Complete the cell phone verification.

    Image: Mobile phone verification

  5. Confirm Email.

    Image: Mobile phone verification

  6. Complete the registration.

    Image: Complete registration

  7. Add the Facebook SDK to your project at Meta for Developers.

2. Create an Application
  1. Click Create App in the upper right corner.

    Image: Create an app

  2. Fill out basic information:

    • App name - FACEBOOK_DISPLAYNAME in the INTLConfig.ini configuration file.
    • App contact email - The primary contact email for receiving notifications from Facebook about the app.

    Image: Enter basic information

  3. The application type is selected as Authenticate and request data from users with Facebook Login.

    Image: Enter basic information

  4. Select Business and continue to the next step if not shown.

    Image: Enter basic information

  5. Agreed and continued.

    Image: Enter basic information

  6. Check the overview, and click Go to Dashboard to complete app creation.

    Image: Enter basic information

3. Configure Application
caution

Enter the Privacy Agreement URL, User Data Deletion, and Terms of Service URLs according to Facebook specifications.If you do not comply with the Facebook Code, Facebook may disable your app after it is published.

note

Apps that have been submitted to Facebook can continue to use Facebook Login For Gaming, new apps that have not been submitted can only use Facebook Login.For more information, see Facebook Login For Gaming.

  1. In the left navigation bar, click App Settings > Basic to view basic information about the application, such as App ID and App secret.

    Image app platform

  2. In the Privacy Policy URL field, enter the URL of the privacy agreement.

  3. In the User Data Deletion field, select the Data Deletion Description URL and enter the URL based on the user's data deletion description.

  4. In the Terms of Service field, enter the URL of the Terms of Service page.

  5. Click Add Platform and select Android to add an Android application.

    Image mobile app platform

  6. Enter the configuration directly, or click Quick Start in the upper right corner of the platform configuration screen to set up the configuration according to the guide.

note

For information on how Key Hashes are generated, see the Official Facebook Guide.

Image: Add platform configuration

  1. Click Save Changes to save the configuration.
Configuring Facebook Login
  1. In the Facebook App Dashboard, click Use cases > Customize.
    Image: Facebook Login Windows
  2. Under Facebook Login select Settings.
  3. At Valid OAuth Redirect URIs, fill in https://common-web.intlgame.com/jssdk/facebooklogincallback.html and https://test-common-web.intlgame .com/jssdk/facebooklogincallback.html.
  4. Open Embedded Browser OAuth Login.
    Image: Facebook Login Windows
  5. Click Save changes at the bottom of the page to save the configuration.
4. Adding tester privileges

Until the app is released, only test users or users who have been added to a permission list can access Facebook features.

  1. In the Facebook App Dashboard, click Roles.
  2. Click Add Administrators/Add Developers/Add Testers to add each role.

Image: Add test user

5. Completion of Facebook Business Certification

Certain Meta technologies or features require Meta Commerce certification before they can be used.For business accreditation, please contact the Player Network assistant.

Image Certification

  1. Obtain Player Network Console login account.
  2. Create a new project for your game, or join an existing one.
  3. Download SDK.
  4. Integrate SDK.
  5. Add Facebook as a login authentication method for business in the Player Network console.

Step 1:Configure SDK for Facebook Login

  1. In the AndroidManifest file, make sure the required permissions are added.Facebook requires access to the web.

    <uses-permission android:name="android.permission.INTERNET"/>
  2. Open your project's INTLConfig.ini file:

    INTLConfig.ini
    [INTL environment]
    # WARNING: You should change this URL to the production environment when you release your game.
    INTL_URL = https://test.intlgame.com
    GAME_ID = {INTL_GAME_ID}
    SDK_KEY = {INTL_SDK_KEY}
    [INTL Log]
    LOG_LEVEL = 1
    LOG_CONSOLE_OUTPUT_ENABLE = 1
    LOG_FILE_OUTPUT_ENABLE = 1
    LOG_ENCRYPT_ENABLE = 0
    LOG_COMPRESS_ENABLE = 0
    [Android LifeCycle]
    LIFECYCLE = Facebook
    [Facebook]
    FACEBOOK_APP_ID = {INTL_FACEBOOK_APP_ID}
    FACEBOOK_DISPLAYNAME = {INTL_APP_NAME}
    • Set the SDK backend environment INTL_URL to https://test.intlgame.com.
    • Replace {INTL_GAME_ID} and {INTL_SDK_KEY} with the values of GAME_ID and SDK_KEY assigned in the Player Network Console.
    • Set LOG_LEVEL = 1, LOG_CONSOLE_OUTPUT_ENABLE = 1, LOG_FILE_OUTPUT_ENABLE = 1, LOG_ENCRYPT_ENABLE = 0 and LOG_COMPRESS_ENABLE = 0 to output console logs and log files without encrypting or compressing the output without encrypting or compressing the output.
    • Add Facebook to LIFECYCLE.For more information, please see SDK Environment.
    • Replace {INTL_FACEBOOK_APP_ID} with Facebook App ID.
    • Replace {INTL_APP_NAME} with the name of the Facebook app.
  3. Define manifestPlaceholders in the gradle file, replacing {INTL_FACEBOOK_APP_ID} with the Facebook App ID.

mainTemplate.gradle
android {
defaultConfig {
manifestPlaceholders = ["FACEBOOK_APPID":"{INTL_FACEBOOK_APP_ID}"]
}
}
  1. Configure ClientToken.A ClientToken can be obtained from the Facebook Developer Platform by going to App Dashboard and selecting App settings/Advanced/Client token.For more information, see Getting Started with the Facebook SDK for Android (https://developers.facebook.com/docs/android/getting-started#add-app_id).

    Image: ClientToken

note

Added ClientToken configuration to the Facebook channel to address an issue where the application fails when the fb graph api is called too many times in a short period of time. This feature is available in V1.19.03 and later.V1.19.02 and earlier versions do not require the following configuration.

Add ClientToken configuration to INTLConfig.ini.

FACEBOOK_CLIENT_TOKEN = CLIENT-TOKEN

Add ClientToken configuration to the projmods file.

"FacebookClientToken":"CLIENT-TOKEN"

Step 2:Add Facebook Login

For Android, Player Network checks the app login status before pulling up the web login.

  • If the Facebook application is installed, Player Network opens the Facebook application for login.
  • If the Facebook application is not installed, Player Network opens the web client for login.

Player Network also supports "Sign in to the Gaming Platform using Facebook".For more information, see the [Technical Implementation] (https://developers.facebook.com/docs/games/acquire/login-for-gaming#technical-implementation) section of the official Facebook documentation.

  1. Register login-related callbacks.
// Add callbacks
public void AddAuthObserver()
{
INTLAPI.AddAuthResultObserver(OnAuthResultEvent);
}

// Remove callbacks
public void RemoveAuthObserver()
{
INTLAPI.RemoveAuthResultObserver(OnAuthResultEvent);
}

// Process the INTLAuthResult callback
public void OnAuthResultEvent(INTLAuthResult ret)
{
Debug.Log($"MethodID: {ret.MethodId}");

string methodTag = "";
if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_LOGIN)
{
methodTag = "Login";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_BIND)
{
methodTag = "Bind";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_AUTOLOGIN)
{
methodTag = "AutoLogin";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_QUERY_USER_INFO)
{
methodTag = "QueryUserInfo";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_GET_AUTH_RESULT)
{
methodTag = "GetAuthResult";
}
}
  1. Call the AutoLogin interface to log in automatically.
INTLAPI.AutoLogin();
  1. If automatic login fails, call the Login interface to let the player log in manually.

    • General Facebook Login
// taking Facebook as example
INTLAPI.Login(INTLChannel.Facebook);
  • Sign in to the Gaming Platform with Facebook

    Call the Login interface with the following parameters to get a Facebook social avatar.For more information, see Requesting a User's Avatar.

// Add a `gaming_user_picture` permission to the original permissions string, something like this:`"email,public_profile,gaming_user_picture"`
public static void Login(string channel, string permissions = "gaming_profile,gaming_user_picture", string extraJson = "{}");
  1. Synchronize client authentication status with the game backend and wait for the final verification result.

[Optional] Set email permission

To get the player's email when logging in to Facebook, you need to set the permission, which will return email in the ChannelInfo of the AuthResult when it's enabled.

  • For compliance considerations, masking of returned email for specific origins can be done. Please contact Player Network Assistant to enable it if needed.
  • In the background log, you can report the hash of base64(sha256(email)). Contact Player Network Assistant if needed.
  • Can be used to verify whether the player's information or the binding list contains email information. Contact Player Network Assistant if needed.
  1. Configure email permission on Meta for Developers.email permission requires Advanced Access Level to allow all apps to obtain the player's email.

    Image Permission Request

  2. When calling the Login interface, add the email permission in the permissions parameter.The Player Network SDK will add email permissions if the permissions parameter is not passed or is empty when calling the Login interface.

  3. Enable the email return feature in the Player Network Console by setting return_email to YES. For details, see Third-Party Channel Configuration.

Step 3: Acceptance testing for login functionality

Search for the keyword "AuthResult" in the Player Network SDK logs to confirm whether the channel name and OpenID are returned correctly.If correct, it means the integration configuration is successful, and login functionality has been successfully added.

If you encounter problems during the integration process, please refer to Frequently Asked Questions.