Tag management API (3.x)

Updated at:
Important

This document applies to the Android SDK 3.x series. Each API notes the minimum required version. If your application uses SDK 4.x, see Tag Management API (4.x).

Bind tags

Bind tags to a device to enable targeted push messaging.

Important
  • An app can have up to 10,000 tags, and each tag can be up to 128 characters long.

  • Binding a tag takes effect within 10 minutes.

  • If a tag is bound to over 100,000 devices, push processing may be delayed. In this case, consider using a broadcast push or segmenting devices with more granular tags.

bindTag

Interface definition

void bindTag(int target, String[] tags, String alias, CommonCallback callback)

Class

CloudPushService

Parameters

Parameter

Type

Required

Description

target

int

Yes

Specifies the target type. Set to 1 or CloudPushService.DEVICE_TARGET.

tags

String[]

Yes

An array of tags to bind.

alias

String

No

A reserved parameter. Pass null.

callback

CommonCallback

Yes

The callback that handles the asynchronous result.

Code sample

PushServiceFactory.getCloudPushService().bindTag(CloudPushService.DEVICE_TARGET, new String[]{tag}, null, new CommonCallback() {
    @Override
    public void onSuccess(String s) {

    }

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

    }
});
PushServiceFactory.getCloudPushService()
    .bindTag(CloudPushService.DEVICE_TARGET, arrayOf(tag), null, object : CommonCallback {
        override fun onSuccess(s: String) {}
        override fun onFailed(errorCode: String, errorMsg: String) {}
    })

Unbind tags

Unbind tags from a device.

Important
  • Unbinding a tag removes its association with a device but does not delete the tag itself. The system does not currently support deleting tags.

  • Unbinding a tag takes effect within 10 minutes.

unbindTag

Interface definition

void unbindTag(int target, String[] tags, String alias, CommonCallback callback)

Class

CloudPushService

Parameters

Parameter

Type

Required

Description

target

int

Yes

Specifies the target type. Set to 1 or CloudPushService.DEVICE_TARGET.

tags

String[]

Yes

An array of tags to unbind.

alias

String

No

A reserved parameter. Pass null.

callback

CommonCallback

Yes

The callback that handles the asynchronous result.

Code sample

PushServiceFactory.getCloudPushService().unbindTag(CloudPushService.DEVICE_TARGET, new String[]{tag}, null, new CommonCallback() {
    @Override
    public void onSuccess(String s) {

    }

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

    }
});
PushServiceFactory.getCloudPushService()
    .unbindTag(CloudPushService.DEVICE_TARGET, arrayOf(tag), null, object : CommonCallback {
        override fun onSuccess(s: String) {}
        override fun onFailed(errorCode: String, errorMsg: String) {}
    })

Query tags

Query the tags bound to a device.

listTags

Interface definition

void listTags(int target, CommonCallback callback)

Class

CloudPushService

Parameters

Parameter

Type

Required

Description

target

int

Yes

Specifies the target type. Set to 1 or CloudPushService.DEVICE_TARGET.

callback

CommonCallback

Yes

The callback that handles the asynchronous result. The query result is returned as the s parameter of the onSuccess method.

Code sample

PushServiceFactory.getCloudPushService().listTags(CloudPushService.DEVICE_TARGET, new CommonCallback() {
    @Override
    public void onSuccess(String s) {

    }

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

    }
});
PushServiceFactory.getCloudPushService()
    .listTags(CloudPushService.DEVICE_TARGET, object : CommonCallback {
        override fun onSuccess(s: String) {}
        override fun onFailed(errorCode: String, errorMsg: String) {}
    })