Account management APIs

Updated at:

This document describes how to use account management APIs to bind an account to a device and unbind an account from a device.

Bind an account

Bind an in-app account to a push channel to send targeted messages to the account.

Note
  • The account name can be up to 64 bytes long.

  • A device can be bound to only one account. An account can be bound to multiple devices.

  • To change the account bound to a device, call the bind API. The new account automatically overwrites the old one. You do not need to unbind the old account first. This prevents concurrency issues caused by frequent operations.

bindAccount

API definition

void bindAccount(String account, CommonCallback callback)

Class

CloudPushService

Parameters

Parameter

Type

Required

Description

account

String

Yes

The account name to bind.

callback

CommonCallback

Yes

The callback for the operation.

Code example

PushServiceFactory.getCloudPushService().bindAccount(account, object : CommonCallback() {
    override fun onSuccess(s: String?) {}
    override fun onFailed(errorCode: String?, errorMsg: String?) {}
})
PushServiceFactory.getCloudPushService().bindAccount(account, new CommonCallback() {
    @Override
    public void onSuccess(String s) {
        
    }

    @Override
    public void onFailed(String errorCode, String errorMsg) {
        
    }
});

Unbind an account

Unbind an in-app account from its push channel.

unbindAccount

API definition

void unbindAccount(CommonCallback callback)

Class

CloudPushService

Parameters

Parameter

Type

Required

Description

callback

CommonCallback

Yes

The callback that reports the success or failure of the operation.

Code example

PushServiceFactory.getCloudPushService().unbindAccount(object : CommonCallback() {
    override fun onSuccess(s: String?) {}
    override fun onFailed(errorCode: String?, errorMsg: String?) {}
})
PushServiceFactory.getCloudPushService().unbindAccount(new CommonCallback() {
    @Override
    public void onSuccess(String s) {
        
    }

    @Override
    public void onFailed(String errorCode, String errorMsg) {
        
    }
});