Authentication

Authentication functions to login/logout, get user info and check status.

Authenticate user

These functions authenticate the user and connect the client via MQTT to Abstrakt’a services.

Login/Create new user account by authenticating with Auth0. This function creates a new account for new users and logs in existing users.

ParameterDescription
emailusername & email of user
passworduser password must have at least 8 characters, 1 lower case, 1 upper case, 1 special character
ReturnDescription
stringreturns *success* or *nil* if authentication failed
Abstrakt.shared.authenticateWithEmailAndPassword(email: String, password: String, completion: @escaping (String) -> Void)

Login/Create new user account by authenticating with Auth0 social auth. This function redirects the user to a social authentication login.

ParameterDescription
audienceauth0 API url that your application will use for authentication. Don't set parameter to use default value.
ReturnDescription
stringreturns *success* or *nil* if authentication failed
Abstrakt.shared.authenticate(audience: String, completion: @escaping (String?) -> Void)

Check if user is already authenticated

Abstrakt.shared.hasCredentials() -> Bool

Get User’s Id

Abstrakt.shared.getUserId() -> String

Get User Avatar

Abstrakt.shared.getUserAvatar() -> String

Get User Name

Abstrakt.shared.getUserName() -> String

Get User Email

Abstrakt.shared.getUserEmail() -> String

Logout and Wipe all local stored data

Abstrakt.shared.logout()

Network Connectivity

Check if SDK is connected to Abstrakt Services

Abstrakt.shared.getConnectionStatus() -> Bool

For debugging and testing only: Reset the current session and re-sync all data from Abstrakt Services

Abstrakt.shared.refreshSession()

For debugging and testing only: Connect to Abstrakt Services. Should happen automatically during authentication

Abstrakt.shared.connectToMQTT() -> Bool