Skip to main content

Authentication

Authenticate

The authenticate method verifies whether the provided user token is correct, you should authenticate the framework using the following method.

parameters
  • token
    • The user token.
Errors
  • Framework not initializated or user not authenticated
MeetingDoctorsError.illegalStateException(reason: .frameworkInitializationFailed))
  • Error while login the user
MeetingDoctorsError.customer(reason: .cantLogin)
  • User not authenticated
MeetingDoctorsError.illegalStateException(reason: .userNotLoged)
  • Error while registering app on Firebase
MeetingDoctorsError.customer(reason: .cantRegisterFirebaseForNotifications)

The token used is the identifier for each user, it can be a DNI, Passport or custom made.

public static func authenticate(token: String) async throws

Implementation example

do {
try await MeetingDoctors.authenticate(token: "token")
} catch {
[...]
}

The result of the authentication does not return any value beyond the error of the operation if failed. Upon a successful response, the user is considered authenticated, and the MeetingDoctors environment is ready to display the user's active conversations.

Logout

Before using the logout method, ensure the SDK has been initialized. If you need to authenticate a user afterward, you can call authenticate after the logout.

The logout method deletes all cached user data, including chat messages and the professional list:

parameters
  • shouldClearPushToken (default true)
    • Logout will remove from the notification center the token of the user.
errors
  • Framework not initializated or user not authenticated
MeetingDoctorsError.illegalStateException(reason: .frameworkInitializationFailed))
  • Indicates the SDK has not been initialized
ControllerError.installationFailed(reason: .nilValueFound())
public static func logout(shouldClearPushToken: Bool = true) async throws

Implementation example

do {
try await MeetingDoctors.logout()
// Handle success
} catch {
// Handle error
}