Start session

Initialisation through CMPComapiChat class gives you access to client object used for any further communication with the SDK.

In order to communicate with Comapi services you need to start session in SDK. This is needed only once per user log in, after that SDK will be re-authenticating session until you end session.


To register or log in user to Comapi services use:

[ startSessionWithCompletion:^{
	// Session started successfully.         
} failure:^(NSError * _Nullable error) {
	// Error occurred.

This will ask CMPAuthenticationDelegate (provided in ChatConfig) for a JWT token then SDK will create session server side for profile id obtained from the token. Any subsequent call to services will use same authentication details.


To close currently opened session use

[ endSessionWithCompletion:^(CMPChatResult * _Nonnull result) {
     if (result.isSuccessful) {
				// Session ended successfully.