Skip to main content
Version: v3

Real-Name Verification and Anti-addiction Guide

tip

Before using the TDS’ Real-Name Verification and Anti-addiction service, please first enable the service on 开发者中心后台 > 游戏服务 > 开发与构建 > 合规认证. When enabling the service, you can select whether your game has gotten an ISBN.

Configure the SDK

You can download the TapSDK from the Downloads page and import the anti-addiction module into your game.

If you are building your game with Unity, you can import a .unitypackage file to your game, which includes the iOS module and the Android module. If you are building with other engines or for other platforms, you can import the iOS or Android module natively. Please refer to the documentation for iOS or Android for more information.

Unity requirement: You will need Unity 2019.4 or higher to use the SDK.

Supported OS versions:

  • Android: 5.0 and higher
  • iOS: 10.0 and higher, Xcode 14.1 or later

The SDK can be imported either using the Unity Package Manager or manually.

Method 1: Use Unity Package Manager

Add the following dependencies into Packages/manifest.json:

"dependencies":{
"com.tapsdk.antiaddiction":"https://github.com/taptap/TapAntiAddiction-Unity.git#3.28.2",
"com.leancloud.storage": "https://github.com/leancloud/csharp-sdk-upm.git#storage-2.3.0",
"com.taptap.tds.common":"https://github.com/TapTap/TapCommon-Unity.git#3.28.2",
}

In Unity’s menu bar, select Window > Package Manager to view the packages already installed in the project.

Method 2: Import Manually

Open the download pages of TapSDK Unity and LeanCloud C# SDK from the Downloads page and download TapSDK-UnityPackage.zip and LeanCloud-SDK-Realtime-Unity.zip from these pages.

  • Import the TapTap_Common_3.28.2.unitypackage and TapTap_AntiAddiction_3.28.2.unitypackage unzipped from TapSDK-UnityPackage.zip.

Configuring for iOS:

Using Xcode 13.0 beta 5 for compiling the project, please follow the steps below to make sure the Xcode project produced by Unity is correctly configured:

  1. Go to Xcode - General - Frameworks, Libraries, and Embedded Content and ensure that AntiAddictionService.framework and AntiAddictionUI.framework are set to Do Not Embed.
  2. If the compilation fails due to missing header files or modules, please make sure the path set in Xcode - Build Settings - Framework Search Paths is correct.
  3. Make sure the Swift Compile Language / Swift Language Version under Build Settings of the Xcode project is Swift5.
  4. Add libz.tbd and libc++.tbd as dependencies.
  5. Write your code to integrate the service.
  6. Copy AntiAddiction-Unity/Assets/Plugins/iOS/Resource/AntiAdictionResources.bundle to your game project (if AntiAddictionResources.bundle is not correctly imported to the Unity project).

The Anti-addiction SDK needs the permissions for connecting to the internet and sending request data. Please make sure to declare those permissions in your project.

Initialize the SDK

During this step, you will be initializing the Anti-addiction UI module, providing configurations for starting the anti-addiction function, and setting up listeners for events related to anti-addiction. Keep in mind that the Identity Verification interface needs to be invoked when the callback is triggered.

using TapTap.AntiAddiction;
using TapTap.AntiAddiction.Model;

AntiAddictionConfig config = new AntiAddictionConfig()
{
gameId = "your_client_id", // The Client ID obtained from the TapTap Developer Center
useTapLogin = true, // Whether to use TapTap Quick Verification
showSwitchAccount = false, // Whether to display the button for switching account
};

Action<int, string> callback = (code, errorMsg) => {
// code == 500; // Logged in
// code == 1000; // Logged out
// code == 1001; // The user tapped the button for switching account
// code == 1030; // The user is not allowed to play games at this time
// code == 1050; // The time limit is reached
// code == 9002; // The user closed the window for real-name verification
UnityEngine.Debug.LogFormat($"code: {code} error Message: {errorMsg}");
};

AntiAddictionUIKit.Init(config, callback);

Parameters

  • config is the configuration for the Anti-addiction service. It contains the following parameters:

    • gameId: The Client ID of the game, which can be found on the Developer Center (开发者中心 > 你的游戏 > 游戏服务 > 应用配置).

    • useTapLogin: Whether to use TapTap Quick Verification. We recommend that you enable this feature so that players who have already confirmed their identities on TapTap can quickly complete the verification process for anti-addiction.

    • showSwitchAccount: Whether to display the button for switching accounts. If your game doesn’t provide the function for players to switch accounts, you can make this button hidden from the user interface. If you choose to have the button displayed (as shown in the image below), the 1001 callback will be triggered when the player hits the button. Your game can handle the player’s request for switching accounts upon receiving this code.

  • callback is the callback interface provided by the SDK to notify users of events. It contains the following parameters:

    • code: The callback type for the event. See Callback Types for more information.

    • errorMsg: If an error occurs, this will be the error message.

The user interface for switching account

Callback Types

Callback codeCallback typeWhen does it get triggered
500LOGIN_SUCCESSLogged in
1000EXITEDLogged out
1001SWITCH_ACCOUNTThe user tapped the button for switching account
1030PERIOD_RESTRICTThe user is not allowed to play games at this time
1050DURATION_LIMITThe time limit is reached
9002REAL_NAME_STOPThe user closed the window for real-name verification

Identity Verification

The SDK provides two methods for you to verify the identities of players:

  1. TapTap Quick Verification: This allows players to authorize your game to use their age range information from TapTap to quickly complete the real-name verification process.
  2. Manual entry: This lets players enter their identity information with the user interface provided by the SDK. In this case, the "TapTap Quick Authentication" box pops up and the "Don't use" button is clicked.

TDS’ server will tell if a player can play your game based on their identity information. The player’s information will be automatically sent to Zhongxuanbu’s system.

We recommend that you adopt the first method so that players won’t have to manually enter their identity information and can start playing your game more quickly.

TapTap Quick Verification

info

Starting from v3.7.1, TapTap Quick Verification doesn’t depend on the TapTap Login SDK anymore, although a player has to be logged in to authorize the game to use their age range information from TapTap. Please make sure you have completed the following steps:

  • Enable TapTap Login. If this step is not completed, the player will see “应用未开通 TapTap 登录服务” when using TapTap Quick Verification.
  • Configure the signature certificate on the Developer Center. If this step is not completed, the player will see “授权失败” when using TapTap Quick Verification.

To enable TapTap Quick Verification, set the parameter for TapTap Quick Verification to true when initializing the SDK.

To start the verification process, you need to provide userIdentifier, the unique identifier of the player. The SDK will then open the TapTap app. If the TapTap app is not installed on the device, a WebView will be opened. The player can then authorize the game to use their age range information from TapTap to complete the real-name verification process in the game.

For userIdentifier, the unique identifier of the player, if your game is using TDS’ built-in account system, you can use the player’s objectId as it; if your game is using the basic TapTap user verification, you can use the player’s openid or unionid.

// The unique identifier cannot be longer than 64 characters
string userIdentifier = "THE_UNIQUE_IDENTIFIER_OF_THE_PLAYER";
AntiAddictionUIKit.Startup(userIdentifier);

Attention: If your Unity project hasn’t integrated the TapTap Login module, you’ll need to configure the URLSchema when creating a package for iOS from the exported Xcode project.

How to configure the `URLSchema` for an Xcode project

Open info.plist and add the following configurations (replace the clientID with the Client ID you obtained from the Developer Center):

<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>taptap</string>
<key>CFBundleURLSchemes</key>
<array>
<!-- Note: The final string should be `tt` concatenated with the Client ID (without brackets). For example: ttFwFdCxxxxxxxQDQwQN -->
<string>tt[clientID]</string>
</array>
</dict>
</array>

<key>LSApplicationQueriesSchemes</key>
<array>
<string>tapiosdk</string>
<string>tapsdk</string>
<string>taptap</string>
</array>

Manual Entry

If you prefer not to enable TapTap Quick Verification, set the parameter for TapTap Quick Verification to false when initializing the SDK.

The format of the userIdentifier, the unique identifier of the player, will be defined by your game. It should be no longer than 64 characters.

Log Out

When a user logs out of your game, you can invoke this method to reset the states of the Anti-addiction service.

AntiAddictionUIKit.Exit();

Obtain Player’s Age Range

Invoke the following interface to get the player’s age range:

int ageRange = AntiAddictionUIKit.AgeRange;

The ageRange in the example above is an integer indicating the minimum age among the age range of the player. If its value is -1, it means that the age range of the user is unknown. This indicates that the user hasn’t verified their identity yet.

ValueMeaning
-1Unknown
00 to 7 years old
88 to 15 years old
1616 to 17 years old
18Adult

Get Remaining Time (In Seconds)

To get the time remaining for the player:

int remainingTimeInSeconds = AntiAddictionUIKit.RemainingTime;

Get Remaining Time (In Minutes)

To get the time remaining for the player:

int remainingTimeInMinutes = AntiAddictionUIKit.RemainingTimeInMinutes;

Check Payment Restrictions

Different payment restrictions are imposed on minors that fall under different age ranges. To enable payment restrictions, you will be checking if restrictions exist before a minor attempts to make a payment. When a payment goes through, you will also be reporting the amount paid to our service.

To check if the current player is allowed to make a payment when your game receives a request from the player to make a payment:

long amount = 100;
AntiAddictionUIKit.CheckPayLimit(amount,
(result) => {
// If `status` is `1`, the player is allowed to make a payment
int status = result.status;
if (status == 1) {
// The player is allowed to make a payment
}
},
(exception) => {
// Handle exception
}
);

The unit of the amount is cent.

To make the function for checking payment restrictions work, your game should be reporting all the payments made by minor players. We recommend that you report payments on the server side. Refer to the description of the relative REST API for more information on how you can report payments on the server side. You can also report payments using the interface provided by the SDK when a minor player successfully makes a payment. However, this is a less reliable method compared to the former one and is often used by games that don’t require connecting to servers.

long amount = 100;
AntiAddictionUIKit.SubmitPayResult(amount,
() => {
// Succeeded
}, (exception) => {
// Handle exception
}
);

When reporting payment amount, the unit of the amount is also cent.

Report Play Time

Invoke the following interface once the player successfully logs in to your game. After that, the SDK will automatically and continuously report the game time of the player.

AntiAddictionUIKit.EnterGame();

Invoke the following interface once the player leaves your game. The SDK will stop reporting the game time of the player.

AntiAddictionUIKit.LeaveGame();

REST API

Request Format

The body of any request sent to the REST API must be a JSON object. The Content-Type in the HTTP header should be application/json.

The Authorization TOKEN HTTP header is used by the server to authenticate requests. To invoke the Anti-addiction REST API, you will first need to obtain a TOKEN on the client using the SDK, then give this TOKEN to the server. The server will then be able to invoke the REST API with this TOKEN.

The API Base is https://tds-tapsdk.cn.tapapis.com.

Obtain the Authentication Token

string token = AntiAddictionUIKit.CurrentToken;

The token obtained here won’t expire.

Check if the Player Can Game

curl -X POST \
-H "Content-Type: application/json" \
-H 'Authorization: {{token}}' \
https://tds-tapsdk.cn.tapapis.com/anti-addiction/v1/clients/{{clientId}}/users/{{userIdentifier}}/playable

Among the request above:

  • {{token}} needs to be replaced with the authentication token obtained by the client.
  • {{clientId}} needs to be replaced with the Client ID obtained from 开发者中心后台游戏服务 > 应用配置.
  • {{userIdentifier}} needs to be replaced with the unique identifier of the player used for identity verification.

The response’s status code will be 200 for the following situations:

// Failed to complete real-name verification
{
"success": true,
"data": {
"status": 2,
"anti_addiction_token": "",
"age_limit": 18,
"has_auth_record": false
}
}

// The player is an adult
{
"success":true,
"data":{
"code":200,
"can_play":true,
"message":"游戏时间不受限制",
"remain_time":60,
"cost_time":0,
"restrict_type":0,
"title":"健康游戏提示",
"description":"当前为成年人账号"
}
}

// The player is a minor and is allowed to game
{
"success":true,
"data":{
"code":200,
"can_play":true,
"message":"游戏允许时间",
"remain_time": {{remainTime}},
"cost_time": {{costtime}},
"restrict_type":1,
"title":"健康游戏提示","description":"你当前为未成年账号,已被纳入防沉迷系统。根据国家相关规定,周五、周六、周日及法定节假日 20 点 - 21 点之外为健康保护时段。你今日游戏时间还剩余${remainTime}分钟,请注意适当休息。"
}
}

// The player is a minor and is not allowed to game
{
"success":true,
"data":{
"code":200,
"can_play":false,
"message":"游戏时间耗尽",
"remain_time": 0,
"cost_time": 60,
"restrict_type":1,
"title":"健康游戏提示",
"description":"你当前为未成年账号,已被纳入防沉迷系统。根据国家相关规定,周五、周六、周日及法定节假日 20 点 - 21 点之外为健康保护时段。当前时间段无法游玩,请合理安排时间。"
}
}

A 401 error will be returned if the token cannot be parsed:

{
"success":false,
"data":{
"code":16,
"error":"实名认证失败",
"error_description":"未实名用户不能进入游戏",
"msg":"该账号没有通过实名认证"
}
}

Check if the Player Can Make Payments

The unit of the payment amount is cent. For example, to check if the player can spend 1 Yuan (100 cents):

curl -X POST \
-H "Content-Type: application/json" \
-H 'Authorization: {{token}}' \
-d '{"amount": 100}' \
https://tds-tapsdk.cn.tapapis.com/anti-addiction/v1/clients/{{clientId}}/users/{{userIdentifier}}/payable

The status code of the response will be 200 no matter if the player is allowed to make the payment:

// Restricted
{
"success":true,
"data":{
"code":200,
"status":false,
"message":"限额提示",
"title":"健康消费提示",
"description":"允许充值根据国家相关规定,未满8周岁:不提供付费服务;8-16周岁以下:单笔付费不超过50元,每月累计不超过200元;16-18周岁以下:单笔付费不超过100元,每月累计不超过400元。"
}
}

// Allowed
{
"success":true,
"data":{
"code":200,
"status":true,
"message":"限额提示",
"title":"健康消费提示",
"description":"允许充值根据国家相关规定,未满8周岁:不提供付费服务;8-16周岁以下:单笔付费不超过50元,每月累计不超过200元;16-18周岁以下:单笔付费不超过100元,每月累计不超过400元。"
}
}

A 400 error will be returned if the amount is malformatted:

{
"success":false,
"data":{
"code":3,
"error":"上传金额不正确",
"error_description":"金额大于等于0并小于100_000_000_000","msg":"请输入正确的金额格式"
}
}

A 401 error will be returned if real-name verification fails (including if the token cannot be parsed):

{
"success":false,
"data":{
"code":16,
"error":"实名认证失败",
"error_description":"未实名用户不能进入游戏",
"msg":"该账号没有通过实名认证"
}
}

Report Payment Amounts

To report that the player has spent 1 Yuan (100 cents):

curl -X POST \
-H "Content-Type: application/json" \
-H 'Authorization: {{token}}' \
-d '{"amount": 100}' \
https://tds-tapsdk.cn.tapapis.com/anti-addiction/v1/clients/{{clientId}}/users/{userIdentifier}/payments

The status code of the response will be 200 if the amount is successfully reported:

{
"success":true,
"data":{"message":"上传金额成功"}
}

A 400 error will be returned if the amount is malformatted:

{
"success":false,
"data":{
"code":3,
"error":"上传金额不正确",
"error_description":"金额大于等于0并小于100_000_000_000","msg":"请输入正确的金额格式"
}
}