Skip to main content

iOS

This article guides you through setting up QQ as an identity provider, enabling your iOS game to access Player Network authentication services.

Prerequisites

1. Set up the QQ app on QQ Connect
1. Create a QQ app
  1. Log in to QQ Connect.

  2. In the sidebar, click App Management.

  3. Click Create App.

    Image: Create an app

  4. Under Mobile App Information, enter the iOS app information.

    • iOS UrlScheme: tencent{INTL_QQ_APP_ID}, replace {INTL_QQ_APP_ID} with the AppID assigned by QQ for your game.

    Image: Mobile App Information

2. Get the app information
  1. Log in to QQ Connect.

  2. In the sidebar, click App Management.

  3. Click Edit in the Action column of the corresponding app.

    Image: Edit Apps

  4. On the app edit page, confirm the AppID and AppKey of the QQ app.

    Image: App Information

3. Apply for OpenAPI is_login permissions for QQ Connect

If the application has not been approved, even if QQ app login is successful, Player Network SDK will still return the error app has no privilege to use this api.
To apply for permissions, send an email according to the following template:

  • To: collinxu@tencent.com; ricesong@tencent.com
  • Cc: chuanhe@tencent.com; vissong@tencent.com; gavinyao@tencent.com; maytang@tencent.com; ricesong@tencent.com; (Product manager); (Technical manager); (Other project members)
  • Subject: [QQ Connect Application] is_login API -- Project XXX
  • Mail contents
    - QQ Connect appid:
    - App name:
    - Company name: (If not Tencent or a wholly owned subsidiary, attach an authorization letter regarding the relationship between the publisher and the developer.)
    - Entry point/scenario of the API: (Attach interactions if necessary.)
    - Timing of call:
    - Purpose of call:
    - Method to obtain accessToken/openkey:
    - Call volume (in minutes):
    - Person-in-charge: (WeCom names of product representative, developer representative.)

For more information, see is_login.

  1. Create an account for Player Network Console.
  2. Create a new project for your game, or join an existing one.
  3. Download the SDK.
  4. Integrate the SDK.
  5. Add QQ as an authentication method for your project on Player Network Console.

Step 1: Configure the SDK for QQ login

  1. Open the project's INTLConfig.ini:

    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

    [QQ channel configuration]
    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 GAME_ID and SDK_KEY assigned by 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.
    • Replace {INTL_QQ_APP_ID} with the AppID assigned by QQ.
  2. Add QQ to the Info.plist file.

    Check the predefined values in INTLCoreKit.projmods and replace {INTL_QQ_APP_ID} with the QQ AppID before exporting the Xcode project from Unity.

    {
    "group": "INTL",
    "libs": [
    "libz.tbd",
    "libstdc++.tbd",
    "libiconv.tbd",
    "libsqlite3.tbd"
    ],
    "frameworks": [
    "Security.framework",
    "SystemConfiguration.framework",
    "CoreTelephony.framework",
    "CoreGraphics.Framework"
    ],
    "files": [
    ],
    "folders": [],
    "excludes": [
    "^.*.meta$",
    "^.*.mdown$",
    "^.*.pdf$"
    ],
    "headerpaths":[],
    "build_settings":
    {
    "OTHER_LDFLAGS": ["-ObjC"],
    "ENABLE_BITCODE": "FALSE",
    },
    "system_capabilities": {
    },
    "Info.plist":{
    "LSApplicationQueriesSchemes":
    [
    "tim",
    "mqq",
    "mqqapi",
    "mqqwpa",
    "mqqbrowser",
    "mttbrowser",
    "mqqOpensdkSSoLogin",
    "mqqopensdkapiV2",
    "mqqopensdkapiV3",
    "mqqopensdkapiV4",
    "wtloginmqq2",
    "mqzone",
    "mqzoneopensdk",
    "mqzoneopensdkapi",
    "mqzoneopensdkapi19",
    "mqzoneopensdkapiV2",
    "mqqapiwallet",
    "mqqopensdkfriend",
    "mqqopensdkdataline",
    "mqqgamebindinggroup",
    "mqqopensdkgrouptribeshare",
    "tencentapi.qq.reqContent",
    "tencentapi.qzone.reqContent"
    ],
    "NSAppTransportSecurity":
    {
    "NSAllowsArbitraryLoads":true
    },
    "CFBundleURLTypes" :
    [
    {
    "CFBundleTypeRole":"Editor",
    "CFBundleURLName":"tencent",
    "CFBundleURLSchemes":["tencent{INTL_QQ_APP_ID}"]
    }
    ],
    }
    }

    Replace {INTL_QQ_APP_ID} with the QQ App ID for the game.

Step 2: Add QQ login

When calling INTLAPI.Login, pass the permission type. It is recommended to pass "all", which indicates all the permissions on the platform that has been applied for.

PermissionsDescription
get_simple_userinfoQQ login permission(Obtain QQ user information on the mobile end)
  1. Add an observer to handle authentication 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";
    }
    }
  2. Call the AutoLogin method.

    INTLAPI.AutoLogin();
  3. Call the Login method to ask for user input if auto-login fails.

    INTLAPI.Login(INTLChannel.QQ, "all", "");
  4. Sync client authentication state with the game's backend and wait for the final authentication result.

Step 3: Test the login function

Search for the keyword "AuthResult" in the Player Network SDK logs to verify if the correct channel name and OpenID are returned. If they are, it indicates a successful configuration and the login function has been added successfully.