TapSDK Quickstart
This article will introduce how to quickly integrate TapSDK into your app and use the TapTap Login function.
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
- Android
- iOS
- Unity 2019.4 or later
- iOS 11 or later, Xcode 14.1 or later
- Android 5.0 (API level 21) or higher
- Android 5.0 (API level 21) or higher
- iOS 11 or later, Xcode 14.1 or later
- 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
- Unity
- Android
- iOS
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
Open the download pages of TapSDK Unity and LeanCloud C# SDK from the Downloads page and download
TapSDK-UnityPackage.zip
andLeanCloud-SDK-Realtime-Unity.zip
from these pages.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).
Drag the unzipped
LeanCloud-SDK-Realtime-Unity.zip
(the Plugins folder) into Unity.
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>
Download TapSDK Android, unzip it, and import the packages you need to
project/app/libs
.Open the
project/app/build.gradle
file under your project and add the following gradle configurations:
dependencies {
...
// Import all aar packages in the libs directory:
implementation fileTree(dir: 'libs', include: ['*.aar'])
// Or import the specified packages in the libs directory:
//implementation files('libs/TapBootstrap_3.29.4.aar')
//implementation files('libs/TapCommon_3.29.4.aar')
//implementation files('libs/TapLogin_3.29.4.aar')
...
// Data Storage
implementation 'cn.leancloud:storage-android:8.2.24'
// Instant Messaging
implementation 'cn.leancloud:realtime-android:8.2.24'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
}
Add the network permission to
AndroidManifest.xml
:<uses-permission android:name="android.permission.INTERNET"></uses-permission>
Add additional configurations for older Android versions.
If
targetSdkVersion < 29
, make sure to:- Add
xmlns:tools="http://schemas.android.com/tools"
intomanifest
- Add
tools:remove="android:requestLegacyExternalStorage"
intoapplication
- Add
Import the SDK
Select the project in Xcode, add
-ObjC
and-Wl -ld_classic
into Build Setting > Other Linker Flags.Download TapSDK iOS, unzip it, and drag and drop the resources you need into the project directory.
Import the downloaded resource files as needed:
Required: TapTap Launcher, Basic Library, and TapTap Login
TapBootstrapSDK.framework
TapCommonSDK.framework
TapLoginSDK.framework
LeanCloudObjc.framework
TapCommonResource.bundle
TapLoginResource.bundle
Please carefully check whether the following dependency libraries are added successfully:
// Required
WebKit.framework
Security.framework
SystemConfiguration.framework
CoreTelephony.framework
SystemConfiguration.framework
libc++.tbd
// TapTap Moments
AVFoundation.framework
CoreTelephony.framework
MobileCoreServices.framework
Photos.framework
SystemConfiguration.framework
WebKit.framework
// Data Analysis
// If you do not need access to the IDFA, please don’t add the system libraries `AppTrackingTransparency` and `AdSupport`.
AppTrackingTransparency.framework
AdSupport.framework
CoreMotion.framework
Security.framework
SystemConfiguration.framework
libresolv.tbd
libsqlite3.0.tbd
libz.tbd
Configure Permissions
If you plan to use TapTap Moments or Data Analysis in your game, please add the following configurations to info.plist
and update the text for the permission dialogue:
<!--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>
Launching the TapTap App From Your Game
If a user does not have the TapTap app on their device, a WebView will be displayed for them to log in.
Open
info.plist
and add the following configurations (replaceclientID
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>Configure openUrl:
a) If the project has
SceneDelegate.m
, please first delete it and then add the following code into theAppDelegate.m
file:```objectivec
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [TDSHandleUrl handleOpenURL:url];
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [TDSHandleUrl handleOpenURL:url];
}
```b) Delete the Application Scene Manifest from
info.plist
.c) Delete the two lifecycle delegate methods for managing
Scenedelegate
fromAppDelegate.m
.```objectivec
#pragma mark - UISceneSession lifecycle
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}
- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
}
```d) Add
UIWindow
toAppDelegate.h
.@property (strong, nonatomic) UIWindow *window;
Initialization
When initializing the TapSDK, please provide the application information including the Client ID
and the region.
- Unity
- Android
- iOS
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);
Make sure to execute the code on the UI thread:
TapConfig tdsConfig = new TapConfig.Builder()
.withAppContext(MainActivity.this) // Context
.withClientId("your_client_id") // (Required) Corresponding Client ID in the Developer Center
.withClientToken("your_client_token") // (Required) Corresponding Client Token in the Developer Center
.withServerURL("https://your_server_url") // (Required) Developer Center > Your Game > Game Services > Configuration > Domain > API
.withRegionType(TapRegionType.CN) // TapRegionType.CN for Mainland China; TapRegionType.IO for International
.build();
TapBootstrap.init(MainActivity.this, tdsConfig);
// Import `TapBootstrap`, `TapLogin`, `TapCommon`, and `LeanCloudObjc`, and then initialize the SDK:
TapConfig *config = [TapConfig new];
config.clientId = @"your_client_id"; // (Required) Corresponding Client ID in the Developer Center
config.clientToken = @"your_client_token"; // (Required) Corresponding Client Token in the Developer Center
config.serverURL = @"https://your_server_url"; // (Required) Developer Center > Your Game > Game Services > Configuration > Domain > API
config.region = TapSDKRegionTypeCN; // TapSDKRegionTypeCN for Mainland China; TapSDKRegionTypeIO for International
[TapBootstrap initWithConfig:config];
client_id
, client_token
, and server_url
are required when you initialize the SDK.
You can find
client_id
andclient_token
on Developer Center > Your Game > Game Services > Configuration.Please use the HTTPS protocol for
server_url
. See Bind Domain Name to learn more aboutserver_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
: