Skip to main content
Version: v4

TapSDK Integration

This document introduces how to quickly integrate TapSDK.

Environment Requirements

  • Unity 2019.4 or higher
  • iOS 11 or higher, Xcode version 15.3 or higher
  • Android 5.0 (API level 21) or higher

Project Configuration

The SDK can be imported either through Unity Package Manager or manually**. Please choose according to your project needs.

Method 1: Use Unity Package Manager

NPMJS Installation

As of version 3.25.0, TapSDK supports NPMJS installation, with the advantage that only the version number needs to be configured and nested dependencies are supported.

Add the following dependencies to your project's Packages/manifest.json file:

"dependencies":{
"com.taptap.sdk.core":"3.29.4",
}

However, it should be noted that scopedRegistries must be declared under the same level of dependencies in Packages/manifest.json:

"scopedRegistries": [
{
"name": "NPMJS",
"url": "https://registry.npmjs.org/",
"scopes": ["com.tapsdk", "com.taptap", "com.leancloud"]
}
]
GitHub Installation

Add the following dependencies to your project's Packages/manifest.json file:

"dependencies":{
"com.taptap.sdk.core":"https://github.com/taptap/TapSDKCore-Unity.git#4.4.0",
}

Select Window > Package Manager in the top menu of Unity to see the packages already installed in your project.

Method 2: Import Manually

  1. Find the download addresses of TapSDK Unity and LeanCloud C# SDK on the download page , and download TapSDK-UnityPackage.zip and LeanCloud-SDK-Realtime-Unity.zip respectively.

  2. In the Unity project, go to Assets > Import Packages > Custom Packages, and from the unzipped TapSDK-UnityPackage.zip, select the TapSDK packages that you want to use in the game, and import them:

    • TapTapSDK_Core.unitypackage TapTapSDK Core Module, Mandatory
  3. The decompresses LeanCloud-SDK-Realtime-Unity.zip is in the Plugins folder, drag and drop it to Unity.

Initialization

When initializing TapSDK, you need to pass in application configuration information such as Client ID and region.

The new version of TapSDK provides unified initialization, and business modules (e.g., achievements, login, etc.) do not need separate initialization.

using TapSDK.Core;

// Core configuration
TapTapSdkOptions coreOptions = new TapTapSdkOptions
{
// Client ID, obtained from the developer backend
clientId = clientId,
// Client Token, obtained from the developer backend
clientToken = clientToken,
// Region, CN for domestic, Overseas for abroad
region = TapTapRegionType.CN,
// Language, default is Auto, by default, zh_Hans for domestic, en for abroad
preferredLanguage = TapTapLanguageType.zh_Hans,
// Whether to enable logging, set to false for Release version
enableLog = true
};
// TapSDK Initialization
TapTapSDK.Init(coreOptions);

// When you need to add initialization configuration items for other modules, such as compliance certification, achievements, etc., please use the following API
TapTapSdkBaseOptions[] otherOptions = new TapTapSdkBaseOptions[]
{
// Other module configuration items
};
TapTapSDK.Init(coreOptions, otherOptions);

During initialization, you must fill in client_id and client_token

  • client_id and client_token information can be found in Developer Center > Your Game > Game Services > Application Configuration.

Integration Features

TapSDK provides numerous features. After initializing the SDK, refer to the documentation of the corresponding features and integrate them as needed for your project. Most games will integrate TapTap login, so we recommend starting with this feature.

Configure Signature Certificate

Android and iOS applications need to go to the TapTap Developer Center, enter your game, and select Game Services > Application Configuration > Signature Certificate Configuration to configure the relevant information of the application (as shown below). Otherwise, when testing the login function for Android applications, a signature not match error message will be returned, and for iOS, a sdk_not_matched error message will be returned, making it impossible to use the TapTap login function normally.

Fill in the MD5 value at the Android signature. For details, please refer to: How to Obtain MD5 Value.

Next, you can package the application and test the TapTap login function.

Android Code Obfuscation

TapSDK has already been obfuscated, and further obfuscation will lead to unexpected errors. Please add the following configuration to your project's obfuscation script to skip the obfuscation operation on TapSDK:

-keep class com.taptap.**{*;}

-keep class com.tapsdk.**{*;}

Packaging

For Android or iOS, just follow the usual Android APK or iOS application packaging process. Here is an introduction to the Unity packaging process:

Packaging APK

Step 1, configure package name and signature file:

Step 2, check File > Build Settings > Player Settings > Other Settings > Target API Level version. When the API Level is less than 29, you need to configure the manifest and add in the application node:

tools:remove="android:requestLegacyExternalStorage"

This is because the SDK internally defaults to android:requestLegacyExternalStorage = true, which will cause an error Android resource linking failed when targetSdkVersion < 29.

Export Xcode Project

You need to configure the icon and BundleID:

Repackaging

Initialization Failure Due to META-INF/services Merge Error

tip

The implementation of TapSDK's initialization framework relies on auto-service, generating META-INF/services/xxx files (service implementation classes) through auto-service, and then using Java's service loader to load them.

The problem often appears as initialization failure, but the essential reason is that during repackaging, the game developer did not correctly merge the files in the META-INF folder.

Type 1: Excluded META-INF/services/com.taptap.sdk.internal.service.ITapAutoService File During Repackaging

This type of problem is common, where developers often do not process all files under META-INF/services (exclude), leading to SDK initialization failure.

Type 2: Error in Merging META-INF/services/com.taptap.sdk.internal.service.ITapAutoService

This means that the developer realized the need to process the files under META-INF/services, but an error occurred during the merge, leading to SDK initialization failure. This type of problem often arises because the developer adopted the override strategy rather than merge during repackaging, which means that when encountering the same file name META-INF/services/com.taptap.sdk.internal.service.ITapAutoService in multiple AARs, only one was retained, leading to SDK initialization failure.

Incorrect merge, as shown:

Correct merge, as shown: