Integrate TapTap Login
Integrate TapTap Login Methods:
- Integrate TapTap login via TDS Authentication System.
- Basic TapTap User Verification.
We recommend the first method for the following scenarios:
- Integrating the account system provided by TapSDK.
- Allowing players to bind additional third-party accounts to their account (Ex: QQ, WeChat, Apple).
- Integrating basic TapSDK system functions in TDS Authentication such as Friends or Achievements.
Otherwise, if you already have an account system and do not plan on using TapSDK functions such as Friends or Achievements, you can integrate TapTap User Login via the second method.
We will introduce the first method and then the second method.
Both methods require visiting Developer Center > Game Services > Integrate Functions to activate TapTap Login.
Check Login Status
The SDK will save the user's login data in the local cache. When your game launches, you can retrieve the login data using the following code. This will allow the player to enter the game without having to log in. Cache will not automatically be cleared.
If the player logs out of the game or clears the game's cache, then the login info will also be deleted.
- Unity
- Android
- iOS
var currentUser = await TDSUser.GetCurrent();
if (null == currentUser)
{
Debug.Log("Not logged in");
// Start logging in
}
else
{
Debug.Log("Logged in");
// Enter the game
}
if (null == TDSUser.currentUser()) {
// Not logged in
} else {
// Logged in; enter the game
}
TDSUser *currentUser = [TDSUser currentUser]
if (currentUser == nil) {
// Not logged in
} else {
// Logged in; enter the game
}
Quick Log-in With TapTap
Regarding TapTap User Login, TapSDK provides special support to developers with the fastest and most convenient integration.
You can call TDSUser.loginWithTapTap
to log in with a press of a button. For example:
- Unity
- Android
- iOS
try
{
// On iOS and Android, the TapTap app will be called or WebView will be used to log in.
// On Windows and macOS, the SDK will display a QR code (default) and a jump link (to be configured).
var tdsUser = await TDSUser.LoginWithTapTap();
Debug.Log($"login sucess:{tdsUser}");
// Get properties of TDSUser
var objectId = tdsUser.ObjectId; // Unique ID
var nickname = tdsUser["nickname"]; // Nickname
var avatar = tdsUser["avatar"]; // Avatar
}
catch (Exception e)
{
if (e is TapException tapError) // using TapTap.Common
{
Debug.Log($"encounter exception:{tapError.code} message:{tapError.message}");
if (tapError.code == TapErrorCode.ERROR_CODE_BIND_CANCEL) // Cancel Login
{
Debug.Log("Login cancelled");
}
}
}
TDSUser.loginWithTapTap(MainActivity.this, new Callback<TDSUser>() {
@Override
public void onSuccess(TDSUser resultUser) {
Toast.makeText(MainActivity.this, "succeed to login with Taptap.", Toast.LENGTH_SHORT).show();
// Developers can call the resultUser method to obtain additional properties.
String userId = resultUser.getObjectId(); // Unique User ID
String avatar = (String) resultUser.get("avatar"); // Avatar
String nickName = (String) resultUser.get("nickname"); // Nickname
}
@Override
public void onFail(TapError error) {
Toast.makeText(MainActivity.this, error.getMessage(), Toast.LENGTH_SHORT).show();
}
}, "public_profile");
[TDSUser loginByTapTapWithPermissions:@[@"public_profile"] callback:^(TDSUser * _Nullable user, NSError * _Nullable error) {
if (user) {
// Developers can call the user method to obtain additional properties.
NSString *userId = user.objectId;
NSString *username = user[@"nickname"];
NSString *avatar = user[@"avatar"];
} else {
NSLog(@"%@", error);
}
}];
After calling the interface above, the TapTap client or a WebView will be opened up to start the log-in process. Once the user finishes authorizing, your app can use the result of the OAuth to finish logging in to the TDS account system.
TDSUser
is the current user's account system. Upon logging in, developers can:
- Visit
objectId
to obtain the user's system ID (the unique identifier), which can be used to bind or match the player on the game server with TDS Authentication. - Visit
nickname
properties to obtain the user's TapTap account name. - Visit
avatar
properties to obtain the TapTap account's avatar.
You can view and manage user accounts by going to the Developer Center.
Obtain User Details
Once TapTap user login is complete, developers can use the following methods to obtain information on TapTap authorization results:
- Unity
- Android
- iOS
var profile = await TapLogin.FetchProfile();
Debug.Log($"profile: {profile.ToJson()}");
Profile profile = TapLoginHelper.getCurrentProfile();
[TapLoginHelper currentProfile]
Profile
will contain the following info:
Parameter | Description |
---|---|
name | The player's nickname on TapTap. |
avatar | The URL of the player's profile picture on TapTap. |
openid | A unique identifier generated from the user's profile and the game's information. Each player has a unique openid in each game. |
unionid | A unique identifier generated from the user's profile and the vendor's information. A player has the same unionid for all the games made by the same vendor, but different ones for different vendors. |
email | The email used by the user to register TapTap |
emailVerified | Whether the email used by the user to register TapTap is verified |
openid
and unionid
are Base64-encoded strings (with padding) containing characters from A-Za-z0-9+/=
.
Since unionid
is strongly associated with the vendor, if your game gets transferred to a different vendor, the unionid
of the users will get changed.
If your game depends on unionid
, our technical support staff will have a discussion with you regarding how the data should be handled so the game will still work properly after being transferred.
User Logout
Players can easily log out by calling logOut
.
- Unity
- Android
- iOS
await TDSUser.Logout();
TDSUser.logOut();
[TDSUser logOut];
PC Login Configurations
Unity SDK 3.5.2 onwards on Windows and macOS supports using a QR code or jump link for players to access the TapTap login page.
SDK supports QR scanning to log in by default.
Jump links must be configured. See below for examples:
Windows
Using a jump link on Windows requires filling out the following configurations in the Registry:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\open-taptap-{client_id}]
@="{Game Name}"
"URL Protocol"="{Program.exe installation path}}"
[HKEY_CLASSES_ROOT\open-taptap-{client_id}]
@="{Game Name}"
[HKEY_CLASSES_ROOT\open-taptap-{client_id}]
[HKEY_CLASSES_ROOT\open-taptap-{client_id}\Shell\Open]
[HKEY_CLASSES_ROOT\open-taptap-{client_id}\Shell\Open\Command]
@="\"{Program.exe installation path}\" \"%1\""
macOS
On macOS, SDK will automatically configure CFBundleURLTypes
.
Use the following steps to configure without errors:
- On Unity, open
BuildSetting
and selectPC, Mac & Linux Standalone
Platform. InTarget Platform
, selectmacOS
. - Check
Create XCode Project
, selectXCode
to compile. - Open output
XCode Project
, selectTarget
, clickInfo
, openURL Types
, inspect whether you have input theURL Scheme
:TapWeb : open-taptap-{clientId}
. If not, then enter:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>TapWeb</string>
<key>CFBundleURLSchemes</key>
<array>
<string>open-taptap-{client_id}</string>
</array>
</dict>
</array>
Additional Functions
View the TDS Authentication Guide for info on the other functions of TDS Authorization.
Video Tutorials
You can refer to the video tutorial:How to Integrate TapTap Login Functionality in Games to learn how to access login functionality in Untiy projects.
For more video tutorials, see Developer Academy. As the SDK features are constantly being improved, there may be inconsistencies between the video tutorials and the new SDK features, so the current documentation should prevail.