Skip to main content

Android

This document introduces how to set up QQ authentication, allowing your game to use Player Network's login authentication service to sign in via the QQ channel.

Prerequisites

1. Set up your game on the QQ Connect platform
1. Create a QQ Application
  1. Log in to QQ Connect

  2. In the sidebar, click App Management.

  3. Click Create Application.

    Image: Create Application

  4. Under Mobile App Information, enter your Android application information.

    • Android package name: Similar to com.intlgame.demo
    • Android signature: Remove the colons (:) from the MD5 signature and convert all letters to lowercase.For example, for MD5=A1:B2..., enter a1b2....
note

The Android signature needs to be obtained using the AppManage tool provided by QQ, and the actual value to input is the MD5 value of the signature file.
For more information, see Android Common Issues.

When configuring multiple package names and signatures for Android in the QQ Connect management console, separate them with an English semicolon (;)

Image: Mobile App Information

2. Obtain Application Information
  1. Log in to QQ Connect

  2. In the sidebar, click App Management.

  3. In the Actions column of the corresponding application, click Edit.

    Image: Edit Apps

  4. On the application edit page, confirm the QQ application's AppID and AppKey.

    Image: App Information

3. Apply for QQ Connect OpenAPI is_login Permission

If the application is not approved, even if QQ app login authorization succeeds, the Player Network SDK backend will return an error app has no privilege to use this api.
Please send an email to apply for permission using the template below:

For more information, see is_login

  1. Enter Player Network Console, create a new project for your game, or join an existing one.
  2. Download SDK.
  3. Integrate SDK.
  4. Add QQ as a login authentication method for your business in the Player Network Console.

Step 1: Configure SDK for QQ Login

  1. 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 = QQ
    [QQ]
    QQ_APP_ID = {INTL_QQ_APP_ID}
    • 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 encrypting or compressing the output without encrypting or compressing the output.
    • Add QQ in LIFECYCLE.For more information, please see SDK Environment.
    • Replace {INTL_QQ_APP_ID} with the AppID assigned by QQ.
  2. In the gradle file, define manifestPlaceholders and replace {INTL_QQ_APP_ID} with QQ AppID.

mainTemplate.gradle
android {
defaultConfig {
manifestPlaceholders = ["QQ_APPID":"{INTL_QQ_APP_ID}"]
}
}
  1. Declare permissions and activities in the AndroidManifest.xml file as shown below.

    AndroidManifest.xml
    <manifest ... >
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    ...
    <application ... >
    <activity android:name="com.example.myapp.MainActivity" ... >
    ...
    </activity>
    ...
    <activity
    android:name="com.tencent.connect.common.AssistActivity"
    android:configChanges="orientation|keyboardHidden"
    android:screenOrientation="behind"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" />

    <activity
    android:name="com.tencent.tauth.AuthActivity"
    android:launchMode="singleTask"
    android:noHistory="true" >
    <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="tencent{INTL_QQ_APP_ID}" />
    </intent-filter>
    </activity>
    ...
    </application>
    ...
    </manifest>

    Replace {INTL_QQ_APP_ID} with the AppID assigned by QQ.

Step 2: Add QQ Login

Pass the permission when calling INTLAPI.Login.It is recommended to pass in "all" to indicate having all the permissions applied for on the platform side.If no permission is passed, Android defaults to using the get_simple_userinfo permission.

PermissionsDescription
get_simple_userinfoQQ login permission (mobile side obtains QQ user information)
  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.
INTLAPI.Login(INTLChannel.QQ, "all", "");
  1. Synchronize client authentication status with the game backend and wait for the final verification result.

Scan code login

Player Network SDK V1.26.00 supports QQ QR code login for both Android and iOS platforms.

By default, if the phone has QQ app installed, it will launch the QQ app for login. If QQ app is not installed, it will automatically switch to QR code login.To modify the default behavior, specify the qrcode_mode parameter in extraJson.

qrcode_modeDescription
autoAuto mode (default):
Prefer to use QQ app login; if QQ app is not installed, QR code login will be used.
force_appForce QQ app login:
If QQ app is not installed, login will return an error.
force_qrcodeForce QR code login:
Regardless of whether QQ app is installed, QR code login will be used.
string permissions = "";
string extraJson = "{\"qrcode_mode\" : \"force_qrcode\"}";
INTLAPI.Login(INTLChannel.QQ, permissions, extraJson);

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.