Basic TapTap User Verification
If you only wish to use TapTap as a login method and do not wish to use any other TDS cloud services, reference this document. Note: If you only select TapTap Login, choosing other cloud services at a later time may result in an upgrade fee.
Getting the SDK
Integrating the basic TapTap Login requires the TapLogin
and TapCommon
modules. Please first download the TapSDK and add the corresponding dependencies.
Initialization
- Unity
- Android
- iOS
TapLogin.Init(string clientID, bool isCn, bool roundCorner);
Parameter Summary
Parameter | Description |
---|---|
clientID | Determines an app's corresponding Client ID in the TapTap Developer Center |
isCn | Depends on the applicable region. true for mainland China, false for International |
roundCorner | Determines if the web page border is rounded when logging in. Rounded=true, straight=false |
LoginSdkConfig config = new LoginSdkConfig();
config.regionType = RegionType.IO;
TapLoginHelper.init(Context context, String clientID, config);
Parameter Summary
Parameter | Description |
---|---|
context | Context generally refers to the current application |
clientID | Determines an app's corresponding Client ID in the TapTap Developer Center |
TTSDKConfig *config = [[TTSDKConfig alloc] init];
config.regionType = RegionTypeIO;
config.roundCorner = YES;
[TapLoginHelper initWithClientID:clientID config:config];
Parameter Summary
Parameter | Description |
---|---|
clientID | Determines an app's corresponding Client ID in the TapTap Developer Center |
regionType | Refers to the conditional region. Mainland China=RegionTypeCN ,other countries/regions=RegionTypeIO |
roundCorner | Determines if the corners are rounded |
Transferring Configurations to TapTap Applications
If the user doesn't have the TapTap application, WebView will open by default.
Open info.plist to add the following configurations, then switch the clientID to the clientID obtained from your console.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>taptap</string>
<key>CFBundleURLSchemes</key>
<array>
<string>tt[clientID]</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tapiosdk</string>
<string>tapsdk</string>
<string>taptap</string>
</array>
If the project has SceneDelegate.m, delete it and add the following code to the AppDelegate.m file.
#import <TapCommonSDK/TapCommonSDK.h>
- (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];;
}
Add UIWindow to AppDelegate.h, then delete the Application Scene Manifest in the info.plist.
@property (strong, nonatomic) UIWindow *window;
TapTap Login and Retrieving Login Results
After the user opens the game, the game can check the login status of the user. If there is already a user logged in, the game can let the user proceed to the game without having to manually log in again.
- Unity
- Android
- iOS
try
{
// On iOS and Android, the SDK will call the TapTap app or WebView to initiate login.
// On Windows and macOS, the SDK will display a QR code (default) and a jump link (to be configured).
var accessToken = await TapLogin.Login();
Debug.Log($"TapTap Login Complete accessToken: {accessToken.ToJson()}");
}
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");
}
}
}
// Fetch TapTap Profile to obtain basic user info, such as their nickname and avatar.
var profile = await TapLogin.FetchProfile();
Debug.Log($"TapTap Login Complete profile: {profile.ToJson()}");
// Instantiating Listener
TapLoginHelper.TapLoginResultCallback loginCallback = new TapLoginHelper.TapLoginResultCallback() {
@Override
public void onLoginSuccess(AccessToken token) {
Log.d(TAG, "TapTap authorization succeed");
// Call TapLoginHelper.getCurrentProfile() to obtain basic user info, such as nickname and avatar.
Profile profile = TapLoginHelper.getCurrentProfile();
}
@Override
public void onLoginCancel() {
Log.d(TAG, "TapTap authorization cancelled");
}
@Override
public void onLoginError(AccountGlobalError globalError) {
Log.d(TAG, "TapTap authorization failed. cause: " + globalError.getMessage());
}
};
// Listener Registration
TapLoginHelper.registerLoginCallback(loginCallback);
// Login
TapLoginHelper.startTapLogin(MainActivity.this, TapLoginHelper.SCOPE_PUBLIC_PROFILE);
[TapLoginHelper registerLoginResultDelegate:delegator];
if ([TapLoginHelper currentProfile]) {
// Already logged in
} else {
[TapLoginHelper startTapLogin:@[@"public_profile"]];
}
// delegator
- (void)onLoginCancel {
// Login cancelled
}
- (void)onLoginError:(nonnull NSError *)error {
// Login failed
}
- (void)onLoginSuccess:(nonnull TTSDKAccessToken *)token {
// Login Complete
}
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.
This information is under fair use for developers.
Check Login Status and User Info
Login status and user info are saved in the local cache, which resets after logging in again. Logging out will clear the cache.
- Unity
- Android
- iOS
// Obtain login status
try
{
var accesstoken = await TapLogin.GetAccessToken();
Debug.Log("Logged in");
// Enter game directly
}
catch (Exception e)
{
Debug.Log("Not logged in");
// Start login
}
// Obtain user info
await TapLogin.GetProfile();
// Obtain real-time user info
await TapLogin.FetchProfile();
// Obtain login status
TapLoginHelper.getCurrentAccessToken();
// Obtain user info
TapLoginHelper.getCurrentProfile();
// Obtain real-time user info
TapLoginHelper.fetchProfileForCurrentAccessToken(new ApiCallback<Profile>() {
@Override
public void onSuccess(Profile data) {
}
@Override
public void onError(Throwable error) {
}
});
// Obtain login status
[TapLoginHelper currentAccessToken];
// Obtain user info
[TapLoginHelper currentProfile];
// Obtain real-time user info
[TapLoginHelper fetchProfileForCurrentAccessToken:^(TTSDKProfile *_Nonnull profile, NSError *_Nonnull error) {}];
Log Out
- Unity
- Android
- iOS
TapLogin.Logout();
TapLoginHelper.logout();
[TapLoginHelper 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 require additional configuration.
Upgrading to TDS Authentication
As mentioned above, if preliminary development only requires TapTap Login as a third-party interface but requires TDS Authentication services later, this will incur a development fee. Details are as follows:
Reference the above guide on Initialization and Quick Log-in With TapTap to complete TapTap Login for TDS Authentication to obtain a TDSUser login.
Obtain the authorized user's
Profile
info. Note: TheProfile
info here must be the same as theProfile
previously obtained from the game. Game developers should be able to use this to find the persistent player data saved on the game server. Otherwise, they can bind the current TDSUser with the original player info. As for the game, developers can decide whether to bind TDSUser with player accounts:- TapSDK doesn't require binding because it saves the cached login status internally. Get
currentUser
when necessary to retrieve the previous TDS login status. - Binding simplifies the process and allows you to expand TDS account info to more third-party platforms.
- TapSDK doesn't require binding because it saves the cached login status internally. Get