Skip to main content

Android

The purpose of this article is to explain how to set up WhatsApp authentication so that your project can use the Player Network login authentication service to login via the WhatsApp channel.

Prerequisites

1. Configure the app on the Meta Developer platform
1. Register an Account
caution

Please use a developer account registered in a WhatsApp-supported region (non-mainland China) for creation. Developer accounts registered in mainland China currently cannot apply for WhatsApp development permissions.

Before configuring the platform for the app, please register a Meta developer account.

  1. Register for an account at Facebook and follow the prompts to complete authentication (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

2. Create a Meta business portfolio

Before configuring the platform for the app, please create a Meta business portfolio.

  1. Visit business.facebook.com and log in using your Meta developer account.

  2. Click the dropdown menu under Home at the top left, then click Create a business portfolio.

  3. Please enter the business portfolio name.This name should match the company or organization's public name, as it will be displayed on Meta.The business portfolio name cannot contain special characters.

    Image: Complete registration

  4. Click Create to complete creation.

3. Create an Application
  1. Login to Meta developer account, go to My Apps, and click Create App in the upper right corner.

    Image: Create an app

  2. Fill out basic information:

    • App name - Application name.
    • App contact email - The primary contact email for receiving notifications about the app from Meta.

    Image: Enter basic information

  3. On the Add Use Case page, select Other, then click Continue.

    Image: Enter basic information

  4. Select Business as the app type, then click Continue.

    Image: Enter basic information

  5. On the Detail page, confirm the application name and email, select the corresponding business portfolio (can be selected later), and click Create app.

note

Business asset portfolio can choose the same company verification method as the Facebook channel app.

Image: Enter basic information

  1. App created successfully.
4. Configure Application
caution

There may be no WhatsApp configuration entry here; this is usually because the developer account does not have WhatsApp development permissions.Only developer accounts registered in WhatsApp-supported regions (non-mainland China) have WhatsApp development permissions; developer accounts registered in mainland China currently cannot apply for WhatsApp development permissions.

  1. After creating the application, find the Add Product button in the left sidebar of the app panel. Under Add Products to Application on the right, find WhatsApp and click the Settings button on the WhatsApp card to complete the addition.

    Image: Configure application

  2. After clicking Settings in the previous step, you will be redirected to the WhatsApp product configuration page. Click Continue directly here.

    Image: Configure application

  3. On the Quickstart interface, click Test the API:

    Image: Configure application

5. Create a System User Token

For long-term testing or production environments, you need to use system user tokens. Please refer to System User Tokens Creation Process.

  1. Refer to the Generate System User Access Tokens section in the link above to create a system user. Select Employee for the user's identity. After creation, please refer to the illustrations in the link to grant the user permissions for the app and the corresponding WhatsApp account.

Image: Create system user token

  1. After authorization, click "Generate Token". In the popup window, select the application, set the token expiry to never expire.

After selecting the following three permissions in the authorization window, click Generate Token to generate

  • business_management
  • whatsapp_business_management
  • whatsapp_business_messaging
caution

The token is displayed only once. Please save it carefully. If lost, you can only regenerate it.

Image: Create system user token

Image: Create system user token

Image: Create system user token

6. Configure WebHook
  1. In WhatsApp, configure the callback address for WebHook.

    Configure the callback address and verification token provided by Player Network, then click verify and save.

Image: Configure WebHook

  1. Configure the types of messages to be received by the WebHook in WhatsApp.

    You need to subscribe to messages

7. Deeplink Redirect Configuration

WhatsApp login feature involves the deeplink redirect capability. Every business integrating WhatsApp channel must configure the deeplink link on the backend. The rule is tentatively set as: xxxxx represents the domain provided by the business, https://xxxxxxxx/whatsapp?info=cccccccccccc. After specifying the domain, you need to configure the redirect file.

Configuration file as follows: https://xxxxxxxxxx/.well-known/assetlinks.json

For instructions on generating assetlinks.json, refer to DeepLink

8. Add official WhatsApp number
note

需准备海外未注册过WhatsApp的手机号,手机号需长期维护保证可用。

  • It is recommended that each business apply for 2 business numbers, one for integration testing and one for production deployment.
  • Reason: Account isolation to prevent sending messages to production users during testing; WhatsApp's callback address can only be configured to one address. If the callback address is set to the production environment, the test environment cannot use this WhatsApp business number for login
  1. Add new official number configuration in the console Image: Add official WhatsApp number
  • Fill out WA Business Profile

    • WhatsApp Business display name: The name displayed to players as the sender identity
    • Timezone: Mainly affects billing and data analytics times. It is recommended to select GMT +8:00 or keep it consistent with the project.
    • Category: Select Other. Choosing Gaming type will prompt that you cannot continue to register for WhatsApp.

    Image: Add official WhatsApp number

  • Add number and verify

    Image: Add official WhatsApp number

  • After verification, it will enter the review stage. You can check the review status on the WhatsApp Manager page.

    Image: Add official WhatsApp number

  1. Complete the Registration operation through API call. The official number becomes available after this is completed.
  • Please refer to the official guide

  • API call solution (you may contact the business interface team for assistance):

    • Complete phone number creation: After successfully applying for a new phone number, you need to call Facebook's API to perform the Register operation.

      curl 'https://graph.facebook.com/v24.0/{wa phone number ID}/register' -H 'Content-Type: application/json' -H 'Authorization: Bearer {token}' -d '{"messaging_product": "whatsapp", "pin": "{wa phone number 2fa pin code}"}'
    • Link phone number with Facebook App: After Register, you need to call Facebook's API to perform the subscribed_apps operation.

9. Others
WhatsApp advertising billing application link
  1. Not settled together with Facebook ad spend. WhatsApp independent billing application link

  2. Settled together with Facebook ad spend. Application link

Set credit quota

It is necessary to contact the Meta Account Manager to assign a credit limit to the Business Manager (BM), or the project may add an available credit card on its own.If you need a credit quota assigned, please contact the Facebook Account Manager for assistance.

Image: Set credit quota

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

Step 1: Configure SDK for WhatsApp Login

  1. Open the 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
    [WhatsApp]
    WHATSAPP_LOGIN_HOST = {INTL_WHATSAPP_LOGIN_HOST}
    WHATSAPP_LOGIN_PATH = {INTL_WHATSAPP_LOGIN_PATH}
    WHATSAPP_SERVICE_ID = {INTL_WHATSAPP_SERVICE_ID}
    • Set the SDK backend environment INTL_URL to https://test.intlgame.com.
    • Replace {INTL_GAME_ID} and {INTL_SDK_KEY} with the GAME_ID and SDK_KEY values assigned by 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 and log files without encryption or compression.
    • Replace {INTL_WHATSAPP_LOGIN_HOST} with the deeplink domain for WhatsApp authorization redirect.
    • Replace {INTL_WHATSAPP_LOGIN_PATH} with the deeplink path for WhatsApp authorization redirect.
    • Replace {INTL_WHATSAPP_SERVICE_ID} with the WhatsApp business phone number.

Step 2: Add WhatsApp Login

Player Network checks the application login status before opening the app for login.

  • If the WhatsApp app is installed, Player Network opens the WhatsApp app for login.
  • If the WhatsApp app is not installed, the Player Network login page will not display the WhatsApp channel login option.
  1. Register login-related callbacks.
// Add callbacks
public void AddAuthObserver()
{
INTLAPI.AddAuthResultObserver(OnAuthResultEvent);
}

public void AddAuthBaseObserver()
{
INTLAPI.AddAuthBaseResultObserver(OnAuthBaseResultEvent);
}

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

public void RemoveAuthBaseObserver()
{
INTLAPI.RemoveAuthBaseResultObserver(OnAuthBaseResultEvent);
}

// 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";
}
}

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

string methodTag = "";
if (ret.MethodId == (int)INTLMethodID.INTL_GET_WHATSAPP_SIG)
{
methodTag = "RequestWhatsAppSignature";
}
}

  1. Invoke the AutoLogin interface to log in automatically.
INTLAPI.AutoLogin();
  1. When automatic login fails, call the RequestWhatsAppSignature interface to obtain the WhatsApp redirect request and carry the code.
INTLAPI.RequestWhatsAppSignature(string ExtraJson);
  1. Send authorization request to WhatsApp business number, receive deeplink click and carry authorization information back to the game, call the LoginForLI interface to log in.
INTLAPI.LoginForLI(INTLChannel.WhatsApp,"",ExtraJson);
  1. Synchronize the client's authentication status with the game backend and await the final validation result.

If you encounter issues during integration, see FAQs.