Skip to main content
Version: v3

TapSDK Quickstart

This article will introduce how to quickly integrate TapSDK into your app and use the TapTap Login function.

note

The Downloads page provides Unity, Android, and iOS demos for your reference.

Creating a Game

Log into the TapTap Developer Center to register as a developer and create a game.

Downloading the TapTap App

Download the TapTap app on your test device. When testing your game, the SDK will take you to the TapTap app for the authorization process. If the TapTap app is not installed on your device, a WebView will be opened for you to log in.

Environment Requirements

  • Unity 2019.4 or later
  • iOS 11 or later, Xcode 14.1 or later
  • Android 5.0 (API level 21) or higher
caution
  • In the Project Configurations and Initialization sections below, we assume that you will use TDS Authentication.
  • If the game already has a complete account system and only needs TapTap Login and Moments without additional TDS cloud services, there is no need for you to complete the configurations and initializations below. You can jump to Basic TapTap Login Developer Guide and Moments Developer Guide.
  • Please make your decision carefully. If you need other TDS services at a later time, it could be hard for you to make a switch.

Project Configuration

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.taptap.tds.login":"https://github.com/TapTap/TapLogin-Unity.git#3.29.4",
"com.taptap.tds.common":"https://github.com/TapTap/TapCommon-Unity.git#3.29.4",
"com.taptap.tds.bootstrap":"https://github.com/TapTap/TapBootstrap-Unity.git#3.29.4",
"com.leancloud.realtime": "https://github.com/leancloud/csharp-sdk-upm.git#realtime-2.3.0",
"com.leancloud.storage": "https://github.com/leancloud/csharp-sdk-upm.git#storage-2.3.0",
}

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

Method 2: Import Manually

  1. 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.

  2. Go to your Unity project, navigate to Assets > Import Packages > Custom Packages, and select the TapSDK packages you want to use from the unzipped TapSDK-UnityPackage.zip file.

    • TapTap_Bootstrap.unitypackage is the TapSDK Launcher (required).
    • TapTap_Common.unitypackage is the TapSDK Basic Library (required).
    • TapTap_Login.unitypackage is for TapTap Login (required).
  3. Drag the unzipped LeanCloud-SDK-Realtime-Unity.zip (the Plugins folder) into Unity.

tip

If you have manually downloaded the unitypackage to import the SDK, please edit the configuration file Assets/TapTap/Common/Plugins/iOS/TapTap.Common.dll to support iOS only.

After importing the SDK, please continue with the following instructions to get your project ready for iOS.

iOS Configuration

Create a file named TDS-Info.plist under the Assets/Plugins/iOS/Resource directory and paste the following code into the file with ClientId replaced with your game’s Client ID. If you plan to use Embedded Moments or Data Analysis, make sure to update the permission configurations accordingly, as well as the text for the permission dialogue:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>taptap</key>
<dict>
<key>client_id</key>
<string>ClientId</string>
</dict>

<!--Embedded Moments requires the access of photo library, camera, and microphone-->
<key>NSPhotoLibraryUsageDescription</key>
<string>Explain why your app requires this permission.</string>
<key>NSCameraUsageDescription</key>
<string>Explain why your app requires this permission.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Explain why your app requires this permission.</string>
<!--TapDB requires the access of IDFA. If you prefer not to show a pop-up, you can do: TapDB.AdvertiserIDCollectionEnabled(false)-->
<key>NSUserTrackingUsageDescription</key>
<string>Explain why your app requires this permission.</string>
</dict>
</plist>

Initialization

When initializing the TapSDK, please provide the application information including the Client ID and the region.

using TapTap.Bootstrap; // Namespace
using TapTap.Common; // Namespace

var config = new TapConfig.Builder()
.ClientID("your_client_id") // (Required) Corresponding Client ID in the Developer Center
.ClientToken("your_client_token") // (Required) Corresponding Client Token in the Developer Center
.ServerURL("https://your_server_url") // (Required) Developer Center > Your Game > Game Services > Configuration > Domain > API
.RegionType(RegionType.CN) // (Optional) CN for Mainland China; IO for international
.ConfigBuilder();
TapBootstrap.Init(config);

client_id, client_token, and server_url are required when you initialize the SDK.

  • You can find client_id and client_token on Developer Center > Your Game > Game Services > Configuration.

  • Please use the HTTPS protocol for server_url. See Bind Domain Name to learn more about server_url.

Integrate Functions

TapSDK provides a variety of functions. After initializing the SDK, feel free to browse the other docs on this site to learn how to enable those functions. One of our popular functions is TapTap Login. We recommend this as the starting point.

Integrate TapTap Login

Follow the Developer Guide Getting Started, Integrate TapTap Quick Login to finish setting up.

Configure Signature Certificate

For Android and iOS applications, go to your game from the Developer Center, then go to Game Services > Gaming Ecosystem > TapTap Login to configure the corresponding app information (see below). Otherwise, the SDK will return a signature not match error, and the TapTap Login function will not work properly.

Fill in the MD5 hash in the "Android Signature" field. See How to get MD5 hash to learn more.

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

Android Code Obfuscation

TapSDK has already undergone obfuscation. Therefore, initiating another obfuscation will lead to unexpected issues. Please add the following configurations in the obfuscation scripts to skip TapSDK obfuscation:

-keep class com.tds.** { *;}
-keep class com.taptap.** { *;}
-keep class com.tapsdk.** { *;}
-keep class tds.androidx.** { *;}

If you plan to use any cloud services based on the Data Storage service (e.g. logging in with TDS Authentication), please also add the obfuscation code for Data Storage.

Package

For Android and iOS apps, you can follow the ordinary packaging process. The following instruction introduces the packaging process for Unity:

Package the APK

Step 1: Configure package name and signature file:

Step 2: Inspect File > Build Settings > Player Settings > Other Settings > Target API Level. If the API Level is below 29, please configure the manifest by adding the following to the application node:

tools:remove="android:requestLegacyExternalStorage"

This is because the SDK is configured with android:requestLegacyExternalStorage = true by default. If targetSdkVersion < 29, the SDK will throw the error Android resource linking failed.

Export Xcode Program

Please configure the icon and BundleID: