Authentication
To use Channelize.io iOS SDK, user authentication with Channelize.io server is required which will return the Access Token in response. This Access Token would be used in the header of Application API calls.
Login / User-Authentication
To ensure that authentic users have access to Channelize.io services, Channelize.io provides two methods of Login / User-Authentication.
Authentication with User ID
This authentication method is useful for any of the below use-cases:
- GDPR and HIPAA compliant applications that don’t save or share users’ personal information like Email ID.
- Applications that have their own authentication process, and can do a token-based Single Sign-On (SSO) with Channelize.io API.
Channelize.login(userId: "userId", accessToken: "accessToken", completion: {(user,errorString) in
guard errorString == nil else{
return
}
// Use the unique ID of the user.
})
Authentication with Email and Password
This authentication method is useful for below use-cases:
- Standalone Chat Applications built with Channelize.io.
- Applications which do not have their own authentication process, and want to use Channelize.io API for primary user authentication as well.
Channelize.login(email: emailAddress, password: "123456", completion: {(user,errorString) in
guard errorString == nil else {
print("Failed to Login with error: \(errorString ?? "")")
}
// Login Successfull
})
Connect
To establish a connection with the Channelize.io server you need to call below method in didFinishLaunchingWithOptions
function of your project's AppDelegate.swift
file for already logged-in user. For logged-out user call below method after login/authentication.
Channelize.connect()
Disconnect
Disconnect the user from the Channelize.io server by calling the following method. Post disconnection, you will not be able to call SDK’s methods and receive event callbacks from the Channelize.io server.
Channelize.disconnect()
Logout
To logout from Channelize.io server, use the below code on logout action button.
Channelize.logout(completion: {(status,errorString) in
guard errorString == nil else {
print("Failed to Logout. Error: \(errorString ?? "")")
return
}
})