Account management APIs (3.x)

Updated at:

Use the account management APIs to bind and unbind accounts for a device.

Important

This document applies to Android SDK 3.x. The minimum version required for each API is specified in its description. References to "later versions" in this document are limited to the 3.x range. For applications that use SDK 4.x, see Account Management APIs (4.x).

Bind an account

Associate an in-app account with a push channel to enable targeted messaging by account.

Note
  • The maximum length for an account name is 64 bytes.

  • A device can be bound to only one account at a time, but an account can be bound to multiple devices.

  • To change the account bound to a device, call the bind API directly. The new account automatically overwrites the old one. You do not need to unbind the previous account first. This approach helps prevent 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 result.

Code sample

PushServiceFactory.getCloudPushService().bindAccount(account, new CommonCallback() {
    @Override
    public void onSuccess(String s) {
        
    }

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

Unbind an account

Disassociates the currently bound account from the push channel.

unbindAccount

API definition

void unbindAccount(CommonCallback callback)

Class

CloudPushService

Parameters

Parameter

Type

Required

Description

callback

CommonCallback

Yes

The callback for the operation result.

Code sample

PushServiceFactory.getCloudPushService().unbindAccount(new CommonCallback() {
    @Override
    public void onSuccess(String s) {
        
    }

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