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
Log in to QQ Connect.
In the sidebar, click App Management.
Click Create App.
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.
- iOS UrlScheme:
2. Get the app information
Log in to QQ Connect.
In the sidebar, click App Management.
Click Edit in the Action column of the corresponding app.
On the app edit page, confirm the AppID and AppKey of the QQ app.
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
.
- Create an account for Player Network Console.
- Create a new project for your game, or join an existing one.
- Download the SDK.
- Integrate the SDK.
- Add QQ as an authentication method for your project on Player Network Console.
Step 1: Configure the SDK for QQ login
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 theGAME_ID
andSDK_KEY
assigned by Player Network Console. - Set
LOG_LEVEL = 1
,LOG_CONSOLE_OUTPUT_ENABLE = 1
,LOG_FILE_OUTPUT_ENABLE = 1
,LOG_ENCRYPT_ENABLE = 0
, andLOG_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.
- Set the SDK backend environment to
Add QQ to the
Info.plist
file.- Unity
- Unreal Engine
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}"]
}
],
}
}- Player Network SDK 1.18 or later
- Before Player Network SDK 1.18
Open and modify the file that corresponds to your SDK version:
- For V1.24 or later:
INTLSDK/Source/INTLQQ/Libs/iOS/INTLQQ_UPL.xml
- For V1.18 to V1.23:
INTLSDK/Source/INTLConfig/Configs/iOS/Plist/INTLQQ.plist
<key>CFBundleURLSchemes</key>
<array>
<string>tencent{INTL_QQ_APP_ID}</string>
</array>Go to Unreal Engine > Settings > Project Settings > Platforms > iOS > Extra Plist Data to modify the configuration,and add SDK to the PLIST file.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>tencent{INTL_QQ_APP_ID}</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tim</string>
<string>mqq</string>
<string>mqqapi</string>
<string>mqqwpa</string>
<string>mqqbrowser</string>
<string>mttbrowser</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqopensdkapiV2</string>
<string>mqqopensdkapiV3</string>
<string>mqqopensdkapiV4</string>
<string>wtloginmqq2</string>
<string>mqzone</string>
<string>mqzoneopensdk</string>
<string>mqzoneopensdkapi</string>
<string>mqzoneopensdkapi19</string>
<string>mqzoneopensdkapiV2</string>
<string>mqqapiwallet</string>
<string>mqqopensdkfriend</string>
<string>mqqopensdkdataline</string>
<string>mqqgamebindinggroup</string>
<string>mqqopensdkgrouptribeshare</string>
<string>tencentapi.qq.reqContent</string>
<string>tencentapi.qzone.reqContent</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>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.
Permissions | Description |
---|---|
get_simple_userinfo | QQ login permission(Obtain QQ user information on the mobile end) |
Add an observer to handle authentication callbacks.
- Unity
- Unreal Engine
// 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";
}
}C++ Event Handling (above v1.15)
//configure callback
FINTLAuthEvent authEvent;
authEvent.AddUObject(this, &OnAuthResult_Implementation);
UINTLSDKAPI::SetAuthResultObserver(authEvent);
// Remove callbacks
UINTLSDKAPI::GetAuthResultObserver().Clear();void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}Unreal Event Handling
void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}Call the
AutoLogin
method.- Unity
- Unreal Engine
INTLAPI.AutoLogin();
UINTLSDKAPI::AutoLogin();
Call the
Login
method to ask for user input if auto-login fails.- Unity
- Unreal Engine
INTLAPI.Login(INTLChannel.QQ, "all", "");
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelQQ, "all", "");
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.