Tag management API
Use the tag management API to bind tags to and unbind tags from a device.
Usage notes
Scope: You can bind tags to and unbind tags from a device.
Tag limits: An application can define up to 10,000 tags. Each tag can be up to 128 characters long, where each Chinese character is counted as a single character.
Effective time: Bind and unbind operations take effect within 10 minutes.
Performance recommendation: Avoid binding more than 100,000 devices to a single tag, as this can cause long processing times and affect response speed. In such cases, consider using a broadcast or splitting devices into more granular tags and calling the push API multiple times.
Unbinding tags: Unbinding a tag only removes the association between the device and the tag; it does not delete the tag. The system does not currently support deleting tags.
Listing tags: You can list the tags currently bound to a device.
Bind tags
Binds one or more tags to a device.
Interface definition
+ (void)bindTag:(int)target
withTags:(NSArray *)tags
withAlias:(NSString *)alias
withCallback:(CallbackHandler)callback;Parameters
Parameter | Type | Required | Description |
target | int | Yes | The target type. Must be 1. |
tags | NSArray<NSString *> | Yes | An array of tags. |
alias | NSString | No | A reserved parameter. Pass |
callback | Block | No | The callback for the operation result. |
Unbind tags
Unbinds one or more tags from a device.
Interface definition
+ (void)unbindTag:(int)target
withTags:(NSArray *)tags
withAlias:(NSString *)alias
withCallback:(CallbackHandler)callback;Parameters
Parameter | Type | Required | Description |
target | int | Yes | The target type. Must be 1. |
tags | NSArray<NSString *> | Yes | An array of tags. |
alias | NSString | No | A reserved parameter. Pass |
callback | Block | No | The callback for the operation result. |
List tags
Lists the tags bound to a device.
Interface definition
+ (void)listTags:(int)target
withCallback:(CallbackHandler)callback;Parameters
Parameter | Type | Required | Description |
target | int | Yes | The target type. Must be 1. |
callback | Block | No | The callback for the operation result. |
Example
CloudPushSDK.listTags(1) { res in
if res.success {
var tags: [String] = []
if let data = res.data as? String, data.count > 0 {
tags = data.components(separatedBy: ",")
}
print("Successfully listed device tags: \(tags)")
} else {
if let error = res.error {
print("Failed to list device tags: \(error)")
}
}
}[CloudPushSDK listTags:1 withCallback:^(CloudPushCallbackResult *res) {
if (res.success) {
NSArray<NSString *> * tags;
if ([res.data length] > 0) {
tags = [res.data componentsSeparatedByString:@","];
}
NSLog(@"Successfully listed device tags: %@", tags);
} else {
NSLog(@"Failed to list device tags: %@", res.error);
}
}];