4b0fccc7d6e310a40465d4f7b9410a6da0b7776e.svn-base
4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package com.thinkgem.jeesite.common.utils;
//import java.util.List;
//
//import com.baidu.yun.channel.auth.ChannelKeyPair;
//import com.baidu.yun.channel.client.BaiduChannelClient;
//import com.baidu.yun.channel.exception.ChannelClientException;
//import com.baidu.yun.channel.exception.ChannelServerException;
//import com.baidu.yun.channel.model.PushBroadcastMessageRequest;
//import com.baidu.yun.channel.model.PushUnicastMessageRequest;
//import com.baidu.yun.core.log.YunLogEvent;
//import com.baidu.yun.core.log.YunLogHandler;
//import com.thinkgem.jeesite.modules.sys.entity.User;
//import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
public class MobileSendMessage {
public static final String apiKey = "oc0yx4ST3dNQcGbXNQUNE2yn";
public static final String secretKey = "KpRboB9HiE6wm7I9IHtcMLnNGZY0S27W";
// /**
// * 无限制推送广播
// * @param title
// * @param content
// */
// public static void pushBroadcastMessage(String title,String content) {
//
// ChannelKeyPair pair = new ChannelKeyPair(MobileSendMessage.apiKey, MobileSendMessage.secretKey);
//
// // 2. 创建BaiduChannelClient对象实例
// BaiduChannelClient channelClient = new BaiduChannelClient(pair);
//
// // 3. 若要了解交互细节,请注册YunLogHandler类
// channelClient.setChannelLogHandler(new YunLogHandler() {
// @Override
// public void onHandle(YunLogEvent event) {
// System.out.println(event.getMessage());
// }
// });
// // 4. 创建请求类对象
// PushBroadcastMessageRequest request = new PushBroadcastMessageRequest();
// request.setDeviceType(3); // device_type => 1: web 2: pc 3:android // 4:ios 5:wp
//
// // request.setMessage("Hello Channel");
// // 若要通知,
// request.setMessageType(1);
// request.setMessage("{\"title\":\""+title+"\",\"description\":\""+content+"\"}");
// //request.setMessage(notify.toString());
//
// // 5. 调用pushMessage接口
// try {
// channelClient.pushBroadcastMessage(request);
// // 6. 认证推送成功
//// System.out.println("push amount : " + response.getSuccessAmount());
// } catch (ChannelClientException e) {
// e.printStackTrace();
// } catch (ChannelServerException e) {
// e.printStackTrace();
// }
//
// }
//
//
// /**
// * 多人员手机提醒信息发送
// * @param title
// * @param content
// * @param users
// */
// public static void pushUnicastMessageMessage(String title,String content,List<String> userIds) {
//
// ChannelKeyPair pair = new ChannelKeyPair(MobileSendMessage.apiKey, MobileSendMessage.secretKey);
//
// // 2. 创建BaiduChannelClient对象实例
// BaiduChannelClient channelClient = new BaiduChannelClient(pair);
//
// // 3. 若要了解交互细节,请注册YunLogHandler类
// channelClient.setChannelLogHandler(new YunLogHandler() {
// @Override
// public void onHandle(YunLogEvent event) {
// System.out.println(event.getMessage());
// }
// });
// // 4. 创建请求类对象
// PushUnicastMessageRequest request = new PushUnicastMessageRequest();
// request.setDeviceType(3); // device_type => 1: web 2: pc 3:android // 4:ios 5:wp
//
// // request.setMessage("Hello Channel");
// // 若要通知,
// request.setMessageType(1);
// request.setMessage("{\"title\":\""+title+"\",\"description\":\""+content+"\"}");
//
// // 5. 调用pushMessage接口
// try {
// for (String userId : userIds) {
// User sendUser=UserUtils.get(userId);
// if(sendUser!=null){
// request.setChannelId(Long.valueOf(sendUser.getMobileChannelId()));
// request.setUserId(sendUser.getMobileUserId());
// channelClient.pushUnicastMessage(request);
// }
// }
//
// // 6. 认证推送成功
//// System.out.println("push amount : " + response.getSuccessAmount());
// } catch (ChannelClientException e) {
// e.printStackTrace();
// } catch (ChannelServerException e) {
// e.printStackTrace();
// }
//
// }
}