Initialisation through CMPComapiChat class gives you access to the client object used for any further communication with the SDK.
In order to communicate with our services you must start a session in the SDK. This is only needed once per user log in. After that, the SDK re-authenticates until you end the session.
Start
To register or log in a user:
[client.services.session startSessionWithCompletion:^{
// Session started successfully.
} failure:^(NSError * _Nullable error) {
// Error occurred.
}];
This asks CMPAuthenticationDelegate
(provided in ChatConfig
) for a JWT token, then the SDK creates a session server-side for profile ID obtained from the token. Any subsequent call to the services uses the same authentication details.
Stop
To close a currently open session:
[client.services.session endSessionWithCompletion:^(CMPChatResult * _Nonnull result) {
if (result.isSuccessful) {
// Session ended successfully.
}
}];