极光推送修改
This commit is contained in:
parent
f355d1da5f
commit
d70e2a6b8b
|
|
@ -26,8 +26,8 @@ public class JpushHelper implements JpushHelperI {
|
||||||
// private static final String masterSecret = "60162c8cf195ce9f4dc76629";
|
// private static final String masterSecret = "60162c8cf195ce9f4dc76629";
|
||||||
// private static final String appKey = "d970d5e193cb2a0bbe41653c";
|
// private static final String appKey = "d970d5e193cb2a0bbe41653c";
|
||||||
//测试
|
//测试
|
||||||
private final static String masterSecret = "a7d41825e75082b13675c326";
|
private final static String masterSecret = "4f759a0609dcd9d2edb06125";
|
||||||
private final static String appKey = "d147124018074eb970474e48";
|
private final static String appKey = "6e5e9d757570859b3f274bb8";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
jPushClient = new JPushClient(masterSecret, appKey);
|
jPushClient = new JPushClient(masterSecret, appKey);
|
||||||
|
|
@ -40,12 +40,12 @@ public class JpushHelper implements JpushHelperI {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean pushMessageByAndroid(String message, String registrationID, Map map) {
|
public boolean pushMessageByAndroid(String title, String message, String userId, Map map) {
|
||||||
try {
|
try {
|
||||||
PushPayload payload = PushPayload.newBuilder()
|
PushPayload payload = PushPayload.newBuilder()
|
||||||
.setPlatform(Platform.android())
|
.setPlatform(Platform.android())
|
||||||
.setAudience(Audience.registrationId(registrationID))
|
.setAudience(Audience.alias(userId))
|
||||||
.setNotification(Notification.android("爱鱼奇提示", message, map))
|
.setNotification(Notification.android(title, message, map))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
PushResult result = jPushClient.sendPush(payload);
|
PushResult result = jPushClient.sendPush(payload);
|
||||||
|
|
@ -65,12 +65,12 @@ public class JpushHelper implements JpushHelperI {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean pushMessageByIOS(String message, String registrationID, Map map) {
|
public boolean pushMessageByIOS(String title, String message, String userId, Map map) {
|
||||||
try {
|
try {
|
||||||
PushPayload payload = PushPayload.newBuilder()
|
PushPayload payload = PushPayload.newBuilder()
|
||||||
.setPlatform(Platform.ios())
|
.setPlatform(Platform.ios())
|
||||||
.setAudience(Audience.registrationId(registrationID))
|
.setAudience(Audience.alias(userId))
|
||||||
.setNotification(Notification.android("爱鱼奇提示", message, map))
|
.setNotification(Notification.ios(message, map))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
PushResult result = jPushClient.sendPush(payload);
|
PushResult result = jPushClient.sendPush(payload);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public interface JpushHelperI {
|
||||||
* @param message
|
* @param message
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean pushMessageByAndroid(String message, String registrationID, Map map);
|
boolean pushMessageByAndroid(String title, String message, String userId, Map map);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向苹果手机推送一条信息
|
* 向苹果手机推送一条信息
|
||||||
|
|
@ -27,5 +27,5 @@ public interface JpushHelperI {
|
||||||
* @param message
|
* @param message
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean pushMessageByIOS(String message, String registrationID, Map map);
|
boolean pushMessageByIOS(String title, String message, String userId, Map map);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package com.ifish.push;
|
|
||||||
|
|
||||||
import cn.jiguang.common.ClientConfig;
|
|
||||||
import cn.jpush.api.JPushClient;
|
|
||||||
import cn.jpush.api.push.model.PushPayload;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Administrator
|
|
||||||
*/
|
|
||||||
public class JiGuangPush {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -80,8 +80,7 @@ public class ExecuteJob implements Job {
|
||||||
Integer deviceId = deviceUser.getDeviceId();
|
Integer deviceId = deviceUser.getDeviceId();
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
String loginType = user.getLoginType();
|
String loginType = user.getLoginType();
|
||||||
String registrationID = user.getJiguangUserid();
|
if (StringUtils.isNotBlank(loginType) && userId != null) {
|
||||||
if (StringUtils.isNotBlank(loginType) && StringUtils.isNotBlank(registrationID)) {
|
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
map.put("device_id", deviceId.toString());
|
map.put("device_id", deviceId.toString());
|
||||||
map.put("device_name", showName);
|
map.put("device_name", showName);
|
||||||
|
|
@ -90,9 +89,9 @@ public class ExecuteJob implements Job {
|
||||||
//极光推送
|
//极光推送
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if (loginType.equals("android")) {
|
if (loginType.equals("android")) {
|
||||||
result = jpushHelperI.pushMessageByAndroid(msg, registrationID, map);
|
result = jpushHelperI.pushMessageByAndroid(title, msg, userId.toString(), map);
|
||||||
} else if (loginType.equals("ios")) {
|
} else if (loginType.equals("ios")) {
|
||||||
result = jpushHelperI.pushMessageByAndroid(msg, registrationID, map);
|
result = jpushHelperI.pushMessageByIOS(title, msg, userId.toString(), map);
|
||||||
}
|
}
|
||||||
if (result) {
|
if (result) {
|
||||||
//推送记录
|
//推送记录
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class SomeServer {
|
public class SomeServer {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserHelperI userHelperI;
|
private UserHelperI userHelperI;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -60,7 +60,7 @@ public class SomeServer {
|
||||||
|
|
||||||
//是否回复心跳
|
//是否回复心跳
|
||||||
public static boolean isReplay = true;
|
public static boolean isReplay = true;
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(SomeServer.class);
|
private static Logger log = LoggerFactory.getLogger(SomeServer.class);
|
||||||
public static ConcurrentHashMap<String, String> remoteAddress = new ConcurrentHashMap<String, String>();
|
public static ConcurrentHashMap<String, String> remoteAddress = new ConcurrentHashMap<String, String>();
|
||||||
public static ConcurrentHashMap<String, IoSession> sessions_cz = new ConcurrentHashMap<String, IoSession>();
|
public static ConcurrentHashMap<String, IoSession> sessions_cz = new ConcurrentHashMap<String, IoSession>();
|
||||||
|
|
@ -310,8 +310,7 @@ public class SomeServer {
|
||||||
//极光推送
|
//极光推送
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
String loginType = user.getLoginType();
|
String loginType = user.getLoginType();
|
||||||
String registrationID = user.getJiguangUserid();
|
if (StringUtils.isNotBlank(loginType) && userId != null) {
|
||||||
if (StringUtils.isNotBlank(loginType) && StringUtils.isNotBlank(registrationID)) {
|
|
||||||
//推送记录
|
//推送记录
|
||||||
Tbl_Push_List pushList = new Tbl_Push_List();
|
Tbl_Push_List pushList = new Tbl_Push_List();
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
|
|
@ -319,11 +318,11 @@ public class SomeServer {
|
||||||
map.put("device_name", showName);
|
map.put("device_name", showName);
|
||||||
map.put("timestamp", timestamp);
|
map.put("timestamp", timestamp);
|
||||||
map.put("msg_type", PushTypeEnum.wendu_warn.getKey());
|
map.put("msg_type", PushTypeEnum.wendu_warn.getKey());
|
||||||
|
|
||||||
if (loginType.equals("android")) {
|
if (loginType.equals("android")) {
|
||||||
result = jpushHelperI.pushMessageByAndroid(msg, registrationID, map);
|
result = jpushHelperI.pushMessageByAndroid(title, msg, userId.toString(), map);
|
||||||
} else if (loginType.equals("ios")) {
|
} else if (loginType.equals("ios")) {
|
||||||
result = jpushHelperI.pushMessageByAndroid(msg, registrationID, map);
|
result = jpushHelperI.pushMessageByIOS(title, msg, userId.toString(), map);
|
||||||
}
|
}
|
||||||
//记录推送
|
//记录推送
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
@ -346,7 +345,7 @@ public class SomeServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue