java服务端对极光推送标签的操作
Posted missccy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java服务端对极光推送标签的操作相关的知识,希望对你有一定的参考价值。
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
以上是关于java服务端对极光推送标签的操作的主要内容,如果未能解决你的问题,请参考以下文章