发送消息给APP的所有人的消息无法收到
在网页端及REST API给所有人发送消息, 设备均收不到消息,这个是怎么回事。 要发送给所有人,只能列出所有的token进行发送吗?
/**
* 通知栏消息接口
* @param client
* @throws NSPException
*/
public static void notification_send(NSPClient client)
throws NSPException
{
//推送范围,必选
//1:指定用户,必须指定tokens字段
//2:所有人,无需指定tokens,tags,exclude_tags
//3:一群人,必须指定tags或者exclude_tags字段
Integer push_type = 1;
//目标用户,可选
//当push_type=1时,该字段生效
String tokens = "00000000000000000000000000000000,00000000000000000000000000000000";
//标签,可选
//当push_type的取值为2时,该字段生效
String tags = "{\"tags\":[{\"location\":[\"ShangHai\",\"GuangZhou\"]},}\"age\":[\"20\",\"30\"]}]}";
//排除的标签,可选
//当push_type的取值为2时,该字段生效
String exclude_tags = "{\"exclude_tags\":[{\"music\":[\"blue\"]},{\"fruit\":[\"apple\"]}]}";
//消息内容,必选
//该样例是点击通知消息打开url连接。更多的android样例请参考> 资料中心 -> Push服务 -> API文档 -> 4.2.1 android结构体
String android =
"{\"notification_title\":\"the good news!\",\"notification_content\":\"Price reduction!\",\"doings\":3,\"url\":\"vmall.com\"}";
//消息发送时间,可选
//如果不携带该字段,则表示消息实时生效。实际使用时,该字段精确到分
//消息发送时间戳,timestamp格式ISO 8601:2013-06-03T17:30:08+08:00
String send_time = "2013-09-03T17:30:08+08:00";
//消息过期时间,可选
//timestamp格式ISO 8601:2013-06-03T17:30:08+08:00
String expire_time = "2013-09-05T17:30:08+08:00";
//构造请求
HashMap hashMap = new HashMap();
hashMap.put("push_type", push_type);
hashMap.put("tokens", tokens);
hashMap.put("tags", tags);
hashMap.put("exclude_tags", exclude_tags);
hashMap.put("android", android);
hashMap.put("send_time", send_time);
hashMap.put("expire_time", expire_time);
//设置http超时时间
client.setTimeout(10000, 15000);
//接口调用
String rsp = client.call("openpush.openapi.notification_send", hashMap, String.class);
//打印响应
//响应样例:{"result_code":0,"request_id":"1380075138"}
System.err.println("通知栏消息接口响应:" + rsp);
}
5
浏览2648 发布于2017-03-27 08:34未知归属地
全部评论
最多点赞
最新发布
最早发布
写回答
所见即所得编辑器, editor1
工具栏
新增插入模板功能
一键使用模板,快速填写内容,轻松发帖~
知道了
- 为了保障您的信息安全,请勿上传您的敏感个人信息(如您的密码等信息)和您的敏感资产信息(如关键源代码、签名私钥、调试安装包、业务日志等信息),且您需自行承担由此产生的信息泄露等安全风险。
- 如您发布的内容为转载内容,请注明内容来源。
我要发帖子
了解社区公约,与您携手共创和谐专业的开发者社区。





































苏公安网备 32011402010933号