Skip to main content

iOS

This article aims to introduce how to set up X authentication, enabling your game to use the Player Network login authentication service to log in through the X channel.

Important

Starting in spring 2024, for apps that need to be updated or uploaded to Apple App Store Connect, developers must clearly declare the reasons for use to show how the app uses required reason API (APIs that require a reason for use to be submitted). For more information, see Upcoming third-party SDK requirements.

Since the X privacy manifest has not been released yet, the Player Network SDK privacy manifest does not include corresponding content. For details, refer to iOS 17 Privacy Manifest.

note

Since the Player Network SDK only supports X web login, the INTLTwitter plugin relies on the WebView component's INTLWKWebViewJavascriptBridge to obtain the login information returned from the X login webpage.

Prerequisites​

1. Set up your game on X Developer website

1. Create X Application​

tip

It is recommended to register your account using a Tencent email to improve the success rate of future applications.

Follow the prompts to register a team or personal developer account on the X Developer website.With a developer account, you can create applications on the Developer Portal.

  1. Create a new project as instructed.

    Image: Create X project

  2. Click the application you created.

    Image: X app

  3. Click Regenerate to obtain the API Key and API Secret Key.

Important

This page will not appear again, so please be sure to save this information.

Image: X API key and API secret key Image: X API key and API secret key

  1. Click Set up.

    Image: X setup

  2. Select Read And Write.

    Image: X app permissions

  3. Select Web App in the application type.

    Image: X OAuth

  4. Add the test environment and production environment URLs as the callback URL.You will be directed to the official website of the game.Click Save Changes.

caution

If the game is already live, you cannot delete the existing callback URL, only add new ones.

Applicable for Player Network SDK V1.15 and earlier versions

https://image.intlgame.com/v2/test/jssdk/twitterlogincallback.html
https://image.intlgame.com/v2/release/jssdk/twitterlogincallback.html

Applicable for Player Network SDK V1.16 and later versions

https://test-common-web.intlgame.com/jssdk/twitterlogincallback.html
https://common-web.intlgame.com/jssdk/twitterlogincallback.html

Image: X callback URLs

2. Retrieve Application Information​

You need the X API Key and API Secret Key to add X login channel in Player Network.

Image: X app information

  1. Go to the Player Network console to create a new project for your game or join an existing project.
  2. Download SDK.
  3. Integrate SDK.
  4. Add X as a business login authentication method in the Player Network console.

Step 1: Configure SDK for X login​

  1. Open the 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
    [X]
    TWITTER_CONSUMER_KEY = {INTL_TWITTER_CONSUMER_KEY}
    TWITTER_CONSUMER_SECRET = {INTL_TWITTER_CONSUMER_SECRET}
    • Set the SDK backend environment to INTL_URL = https://test.intlgame.com.
    • Replace {INTL_GAME_ID} and {INTL_SDK_KEY} with the values of GAME_ID and SDK_KEY 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 logs and log files without encryption or compression.
    • Replace {INTL_TWITTER_CONSUMER_KEY} and {INTL_TWITTER_CONSUMER_SECRET} with the X API key and API Key Secret.

Step 2: Add X login​

After the user logs in, choose the X channel to proceed with binding.If the user has already used a bound X account, a server error will be prompted.Invoking the Bind interface again will require the user to log in to X again.

  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 AuthResult)
{
Debug.Log($"MethodID: {AuthResult.MethodId}");

string methodTag = "";
switch (AuthResult.MethodId)
{
case (int)INTLMethodID.INTL_AUTH_LOGIN:
methodTag = "Login";
break;
case (int)INTLMethodID.INTL_AUTH_BIND:
methodTag = "Bind";
break;
case (int)INTLMethodID.INTL_AUTH_AUTOLOGIN:
methodTag = "AutoLogin";
break;
case (int)INTLMethodID.INTL_AUTH_QUERY_USER_INFO:
methodTag = "QueryUserInfo";
break;
case (int)INTLMethodID.INTL_AUTH_GET_AUTH_RESULT:
methodTag = "GetAuthResult";
break;
}
}
  1. Call the AutoLogin interface for automatic login.
INTLAPI.AutoLogin();
  1. If automatic login fails, call the Login method to let players log in manually.
INTLAPI.Login(INTLChannel.Twitter);
  1. Synchronize client authentication status with the game backend, waiting for final validation results.

[Optional] Set email permissions​

To obtain the player's email during X login, you must first enable the corresponding permission. After enabling, email will be returned in the ChannelInfo of AuthResult.

  • For compliance reasons, the returned email can be masked for specific sources. If needed, please contact the Player Network assistant to enable it.
  • You can report base64(sha256(email)) in backend logs after hashing. If needed, please contact Player Network Assistant to enable.
  • Can be used to verify whether player information or the bind list contains email information. If needed, please contact Player Network Assistant to enable.
  • Can be used for iOS Firebase's Private Set Membership (PSM) feature. See Firebase iOS Project Configuration.
  1. On X Developer Platform in Edit settings under OAuth 2.0 keys, check Request email from users.

    Image: OAUTH1.OA SETTINGS
  2. Enable email return in the Player Network Console by setting return_email to YES. For details, please see Third-party channel configuration.

Step 3: Acceptance of Login Functionality​

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

If you encounter problems during integration, refer to FAQs.