Skip to main content

Authentication

Authenticate

Authentication verifies that the provided user token is correct and, therefore, it can initiate the chat.

MeetingDoctors.authenticate(token: "token") { (result: MeetingDoctorsResult<Void>) in
switch result {
case .success:
[...]
case .failure(let error):
[...]
}
}

The result of the authentication does not return any value beyond the same verification of success or failure of the operation.

From a successful response, we can consider that the user is authenticated and MeetingDoctors environment is ready to show the active conversations of the user.

info

In the case of this example project you can find this snippet in the class ViewController.

Shutdown

A shutdown method exists so a chat user can disconnect and erase all sensible information:

MeetingDoctors.shutdown { (result: MeetingDoctorsResult<Void>) in
switch result {
case .success:
[...]
case .failure(let error):
[...]
}
}

This operation removes all user concerning information, so once a user is deauthenticated, a call to authenticate must be invoked to access the contact list again.

Logout

First, you must initialize SDK previously to call this method. If you want to call method authenticate, please call it inside logout clousure.

A logout method delete all user cached data, including chat messages and professional list:

MeetingDoctors.logout(shouldClearPushToken: true) { result in
switch result {
case .success:
[...]
case .failure(let error):
[...]
}
}

By default the parameter shouldClearPushToken is setup to true. So any logout will remove from the notification center the token of the user.

MeetingDoctors.logout { result in
switch result {
case .success:
[...]
case .failure(let error):
[...]
}
}

If the integrator wants to switch to a different user but continue to receive the push notifications from previous user, the parameter shouldClearPushToken can be setup to false.

MeetingDoctors.logout(shouldClearPushToken: false) { result in
switch result {
case .success:
[...]
case .failure(let error):
[...]
}
}