Authentication
In order to use the abilities of the iOS SDK in your client app, a TapTalk instance must be initiated in each client app through user authentication with TapTalk.io server. An authenticated user account allows the instance to communicate and interact with the server. The following explains how to authenticate your user with the server.
TapTalk.io's Authentication Flow
When the user logs in to your application, your backend server will have to request an Authentication Ticket from TapTalk.io server. TapTalk.io server will return the requested Authentication Ticket and user ID to your backend server. The client application (iOS or Android) can then retrieve the ticket from your backend server to implement TapTalk.io's SDK by initializing the SDK using the obtained Authentication Ticket.
You can see the documentation on how to obtain Authentication Ticket from TapTalk.io's Server on the Authentication in TapTalk.io's Server API page.

Authenticate to TapTalk.io server with an Authentication Ticket

Note: authentication should only be called once before the user is logged in or when the callback onTapTalkRefreshTokenExpired() is triggered in TapListener
Java
Kotlin
1
TapTalk.authenticateWithAuthTicket(AUTH_TICKET, CONNECT_ON_SUCCESS, new TapCommonListener() {
2
@Override
3
public void onSuccess(String successMessage) {
4
// Authentication successful
5
}
6
7
@Override
8
public void onError(String errorCode, String errorMessage) {
9
10
}
11
});
Copied!
1
TapTalk.authenticateWithAuthTicket(AUTH_TICKET, CONNECT_ON_SUCCESS, object : TapCommonListener() {
2
override fun onSuccess(successMessage: String?) {
3
// Authentication successful
4
}
5
6
override fun onError(errorCode: String?, errorMessage: String?) {
7
8
}
9
})
Copied!
Parameters AUTH_TICKET : (String) an authentication ticket is required for this method CONNECT_WHEN_SUCCESS: (BOOL) if set to YES, application will connect to TapTalk.io server after authentication is successfully completed

Check Authentication Status

You can check authentication status by calling isAuthenticated() method
Java
Kotlin
1
boolean isAuthenticated = TapTalk.isAuthenticated();
Copied!
1
var isAuthenticated = TapTalk.isAuthenticated()
Copied!

Logout and Clear TapTalk.io Data

Call this method when you need to logout and clear all local cached data from TapTalk.io.
Java
Kotlin
1
//Logout from TapTalk.io
2
TapTalk.logoutAndClearAllTapTalkData();
Copied!
1
//Logout from TapTalk.io
2
TapTalk.logoutAndClearAllTapTalkData()
Copied!

Clear TapTalk.io Data

You can clear all TapTalk.io local cached data by calling clearAllTapTalkData() method.
Java
Kotlin
1
TapTalk.clearAllTapTalkData();
Copied!
1
TapTalk.clearAllTapTalkData()
Copied!