Integration & Authentication
Integrate & Authenticate API SDK
Step 1: Initialize the SDK
Initialize SDK with your Public key, which will bind the SDK to Android’s context, thereby allowing it to respond to the connection and state changes. The Channelize.initialize(channelizeConfig)
method should be called once across the application. Initializing the Android SDK in the onCreate()
method of the Application instance is recommended.
ChannelizeConfig channelizeConfig = new ChannelizeConfig.Builder(this)
.setLoggingEnabled(true) // Set true, if you want to see Channelize.io SDK logs in the development mode otherwise set it to false.
.setAPIKey(PUBLIC_KEY).build();
Channelize.initialize(channelizeConfig);
Step 2: Connect to Channelize.io server
This may vary based on your requirements. If you want your app to get real-time updates in the entire life cycle, then call this method in the onCreate()
method of the application instance. If you want to get the real-time events only when a screen is launched or a CTA is clicked, then you can call this method at that time.
Note: Only logged in users can connect to Channelize.io server.
Channelize.connect();
Disconnect from Channelize.io server
// Disconnect logged in user from our server to stop receiving further notifications, messages and event notifications.
Channelize.disconnect();
Step 3: Login / User-Authenticate to Channelize.io server
To ensure that authentic users have access to Channelize.io services, Channelize.io provides two methods of Login / User-Authentication.
1: Authentication with User ID
Channelize.getInstance().loginWithUserId("USER_ID", "CLIENT_SERVER_ACCESS_TOKEN", new CompletionHandler<LoginResponse>() {
@Override
public void onComplete(LoginResponse result, ChannelizeError error) {
}
});
2: Authentication with Email and Password
Channelize.getInstance().loginWithEmailPassword("YOUR_EMAIL", "YOUR_PASSWORD", new CompletionHandler<LoginResponse>() {
@Override
public void onComplete(LoginResponse result, ChannelizeError error) {
}
});
Logout from Channelize.io server
Channelize.logout();