1.根据注册id打标签
/**
*根据rid修改标签,和 alias
* @param tagSet
* @param registrationId
* @param alias
* @return
*/
public DefaultResult updateDeviceTagAlias(HashSet<String> tagSet,String registrationId ,String alias) {
JPushClient jPushClient = JGClientMgr.getCustomClient(JGConfigMgr.getInstance().getJGConfig());
//HashSet<String> tagSet = new HashSet<String>();
//tagSet.add(tag);
DefaultResult result = null;
try {
result = jPushClient.updateDeviceTagAlias(registrationId, alias, tagSet,null);
Logger.info("Got result " + result);
} catch (APIConnectionException e) {
Logger.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
Logger.error("Error response from JPush server. Should review and fix it. ", e);
Logger.info("HTTP Status: " + e.getStatus());
Logger.info("Error Code: " + e.getErrorCode());
Logger.info("Error Message: " + e.getErrorMessage());
}
return result;
}
2.根据注册id去除标签
public DefaultResult removeDeviceTag(HashSet<String> tagSet,String registrationId ,String alias) {
JPushClient jPushClient = JGClientMgr.getCustomClient(JGConfigMgr.getInstance().getJGConfig());
//HashSet<String> tagSet = new HashSet<String>();
//tagSet.add(tag);
DefaultResult result = null;
try {
result = jPushClient.updateDeviceTagAlias(registrationId, null, null,tagSet);
Logger.info("Got result " + result);
} catch (APIConnectionException e) {
Logger.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
Logger.error("Error response from JPush server. Should review and fix it. ", e);
Logger.info("HTTP Status: " + e.getStatus());
Logger.info("Error Code: " + e.getErrorCode());
Logger.info("Error Message: " + e.getErrorMessage());
}
return result;
}
jPushClient.updateDeviceTagAlias(registrationId, alias, tagSetAdd,tagSetRemove)
根据registrationId设置别名为alias,设置标签为tagSetAdd,去除标签为tagSetRemove