|
@@ -26,8 +26,8 @@ import org.springframework.stereotype.Service;
|
26
|
26
|
import javax.annotation.Resource;
|
27
|
27
|
import java.net.URI;
|
28
|
28
|
import java.net.URISyntaxException;
|
|
29
|
+import java.util.Collection;
|
29
|
30
|
import java.util.HashMap;
|
30
|
|
-import java.util.List;
|
31
|
31
|
import java.util.Map;
|
32
|
32
|
|
33
|
33
|
|
|
@@ -38,6 +38,8 @@ public class JpushServiceImpl implements JpushService {
|
38
|
38
|
@Resource
|
39
|
39
|
JpushConfig jpushConfig;// 注入配置信息
|
40
|
40
|
|
|
41
|
+
|
|
42
|
+
|
41
|
43
|
/**
|
42
|
44
|
* 推送自定义消息,不创建通知栏提醒,由APP端拦截信息后再决定是否创建通知
|
43
|
45
|
*
|
|
@@ -47,7 +49,7 @@ public class JpushServiceImpl implements JpushService {
|
47
|
49
|
* @param registrationIds 手机注册ID,设定哪些用户手机能接收信息
|
48
|
50
|
*/
|
49
|
51
|
@Override
|
50
|
|
- public PushResult sendMessagePush(String title, String content, Map<String, String> extras, List<String> registrationIds) {
|
|
52
|
+ public PushResult sendMessagePush(String title, String content, Map<String, String> extras, Collection<String> registrationIds) {
|
51
|
53
|
ClientConfig clientConfig = getClientConfig();
|
52
|
54
|
|
53
|
55
|
// 使用NativeHttpClient网络客户端,连接网络的方式,不提供回调函数
|
|
@@ -83,7 +85,7 @@ public class JpushServiceImpl implements JpushService {
|
83
|
85
|
*
|
84
|
86
|
*/
|
85
|
87
|
@Override
|
86
|
|
- public PushResult sendNotificationPush(String title, String content, Map<String, String> extras, List<String> registrationIds) {
|
|
88
|
+ public PushResult sendNotificationPush(String title, String content, Map<String, String> extras, Collection<String> registrationIds) {
|
87
|
89
|
ClientConfig clientConfig = getClientConfig();
|
88
|
90
|
|
89
|
91
|
// 使用NativeHttpClient网络客户端,连接网络的方式,不提供回调函数
|
|
@@ -120,7 +122,7 @@ public class JpushServiceImpl implements JpushService {
|
120
|
122
|
* @see "使用NettyHttpClient,异步接口发送请求",通过回调函数可以获取推送成功与否情况
|
121
|
123
|
*/
|
122
|
124
|
@Override
|
123
|
|
- public void sendNotificationPushWithCallback(String title, String content, Map<String, String> extras, List<String> registrationIds) {
|
|
125
|
+ public void sendNotificationPushWithCallback(String title, String content, Map<String, String> extras, Collection<String> registrationIds) {
|
124
|
126
|
ClientConfig clientConfig = getClientConfig();
|
125
|
127
|
String host = (String) clientConfig.get(ClientConfig.PUSH_HOST_NAME);
|
126
|
128
|
final NettyHttpClient client = new NettyHttpClient(
|
|
@@ -158,7 +160,7 @@ public class JpushServiceImpl implements JpushService {
|
158
|
160
|
/**
|
159
|
161
|
* 构建Android和IOS的推送通知对象
|
160
|
162
|
*/
|
161
|
|
- private PushPayload buildNotificationPushPayload(String title, String content, Map<String, String> extras, List<String> registrationIds) {
|
|
163
|
+ private PushPayload buildNotificationPushPayload(String title, String content, Map<String, String> extras, Collection<String> registrationIds) {
|
162
|
164
|
if (extras == null || extras.isEmpty()) {
|
163
|
165
|
extras = new HashMap<>();
|
164
|
166
|
}
|
|
@@ -175,7 +177,7 @@ public class JpushServiceImpl implements JpushService {
|
175
|
177
|
/**
|
176
|
178
|
* 构建Android和IOS的自定义消息的推送消息对象
|
177
|
179
|
*/
|
178
|
|
- private PushPayload buildMessagePushPayload(String title, String content, Map<String, String> extras, List<String> registrationIds) {
|
|
180
|
+ private PushPayload buildMessagePushPayload(String title, String content, Map<String, String> extras, Collection<String> registrationIds) {
|
179
|
181
|
return PushPayload.newBuilder().setPlatform(Platform.android_ios())
|
180
|
182
|
.setAudience(Audience.registrationId(registrationIds))
|
181
|
183
|
.setMessage(Message.newBuilder().setTitle(title).setMsgContent(content).addExtras(extras).build())
|