Alias management APIs (3.x)
This topic applies to Android SDK 3.x. The minimum required version varies by API. All references to "and later versions" are within the 3.x series. For applications that use version 4.x, see Alias management APIs (4.x).
Add an alias
Adds an alias to a device to enable targeted message pushes.
-
A device can have up to 128 aliases. An alias can be added to up to 128 devices.
-
An alias can be up to 128 bytes in length.
addAlias
API definition
void addAlias(String alias, CommonCallback callback)
Class
CloudPushService
Parameters
|
Parameter |
Type |
Required |
Description |
|
alias |
String |
Yes |
The alias to add. |
|
callback |
CommonCallback |
Yes |
The callback for the operation result. |
Code examples
PushServiceFactory.getCloudPushService().addAlias(alias, new CommonCallback() {
@Override
public void onSuccess(String s) {
}
@Override
public void onFailed(String errorCode, String errorMsg) {
}
});PushServiceFactory.getCloudPushService()
.addAlias(alias, object : CommonCallback {
override fun onSuccess(s: String) {}
override fun onFailed(errorCode: String, errorMsg: String) {}
})Delete an alias
Deletes an alias from a device.
You can delete a specific alias or all aliases from the device.
removeAlias
API definition
void removeAlias(String alias, CommonCallback callback)
Class
CloudPushService
Parameters
|
Parameter |
Type |
Required |
Description |
|
alias |
String |
No |
If this parameter is |
|
callback |
CommonCallback |
Yes |
The callback for the operation result. |
Code examples
PushServiceFactory.getCloudPushService().removeAlias(alias, new CommonCallback() {
@Override
public void onSuccess(String s) {
}
@Override
public void onFailed(String errorCode, String errorMsg) {
}
});PushServiceFactory.getCloudPushService()
.removeAlias(alias, object : CommonCallback {
override fun onSuccess(s: String) {}
override fun onFailed(errorCode: String, errorMsg: String) {}
})Query aliases
Queries the aliases of a device.
-
Since SDK v3.0.9, this API uses a 5-second internal cache. Multiple calls within this 5-second window send only one request to the server.
listAliases
API definition
void listAliases(CommonCallback callback)
Class
CloudPushService
Parameters
|
Parameter |
Type |
Required |
Description |
|
callback |
CommonCallback |
Yes |
The callback for the query result, which is available in the |
Code examples
PushServiceFactory.getCloudPushService().listAliases(new CommonCallback() {
@Override
public void onSuccess(String s) {
}
@Override
public void onFailed(String errorCode, String errorMsg) {
}
});PushServiceFactory.getCloudPushService()
.listAliases(object : CommonCallback {
override fun onSuccess(s: String) {}
override fun onFailed(errorCode: String, errorMsg: String) {}
})