jpush app 消息推送项目 实例
来源:互联网 发布:galgame机翻软件 编辑:程序博客网 时间:2024/06/07 07:37
1、jpush 推送 用的比较多的是 别名:alias 以及 标签 tag 推送
2、下载jpush-client-3.2.3.jar
3、appkey、Secret 在数据库配置、开放如下接口
public void pushToUser(String appid, String userId, MobilePushEntity pushEntity);
public void pushToUserList(String appid, List<String> userIdList, MobilePushEntity pushEntity);
public void pushToDevice(String appid, List<String> deviceTokenList, MobilePushEntity pushEntity);
public void pushToApp(String appid, MobilePushEntity pushEntity);
4、代码结构如下:
3、核心推送代码如下:
// 如果是IOS,设置平台特性
if (deviceType.equals(DeviceType.IOS)) {
// IOS内容的长度限制
String notificationContent = pushEntity.getMsgContent();
if (StringUtils.isNotBlank(notificationContent) && notificationContent.getBytes().length > 70) {
notificationContent = StringUtilsEx.substringb(notificationContent, 70) + "...";
}
IosNotification.Builder iosNotificationBuilder = IosNotification.newBuilder().setAlert(notificationContent).setBadge(1)
.setSound("default");
for (String key : extrasMap.keySet()) {
iosNotificationBuilder.addExtra(key, String.valueOf(extrasMap.get(key)));
}
payloadBuilder.setNotification(Notification.newBuilder().addPlatformNotification(iosNotificationBuilder.build()).build());
} else {
AndroidNotification.Builder androidNotificationBuilder = AndroidNotification.newBuilder()
.setAlert(pushEntity.getMsgContent()).setTitle(pushEntity.getMsgTitle());
for (String key : extrasMap.keySet()) {
androidNotificationBuilder.addExtra(key, String.valueOf(extrasMap.get(key)));
}
payloadBuilder.setNotification(Notification.newBuilder().addPlatformNotification(androidNotificationBuilder.build())
.build());
}
PushPayload pushPayload = payloadBuilder.build();
for (String[] jpushInfo : JpushInfoList) {
try {
JPushClient jPushClient = new JPushClient(jpushInfo[0], jpushInfo[1], iosMode,
(pushEntity.getJpushTimeToLive() == null ? 86400 : pushEntity.getJpushTimeToLive()));
jPushClient.sendPush(pushPayload);
} catch (Exception e) {
// 个推时如果手机端没有注册用户,不打错误日志
if (e.getMessage().indexOf("\"code\": 1011") == -1) {
logger.error("JPUSH推送消息时发生异常:[" + e.getMessage() + "]", e);
}
}
}
} catch (Exception e) {
if (e.getMessage().indexOf("\"code\": 1011") == -1) {
logger.error("JPUSH推送消息时发生异常:[" + e.getMessage() + "]", e);
}
}
- jpush app 消息推送项目 实例
- IONIC项目JPUSH消息推送IOS集成
- JPush 服务器消息推送
- JPush 推送消息给 Android
- JPush实现app推送功能
- android消息推送---JPush(极光推送)
- C# Jpush 极光推送消息推送教程
- 如何用好消息推送(JPush)为app拉新、留存、促活
- 用JPUSH极光推送实现服务端向安装了APP应用的手机推送消息(C#服务端接口)
- 用JPUSH极光推送实现服务端向安装了APP应用的手机推送消息(C#服务端接口)
- Unity集成JPush本地消息推送问题
- android Fragment接收Jpush推送消息
- React Native Android JPush消息推送集成
- JPush手机APP推送简单总结-极光
- 推送消息的时候判断是在app里面还是点击消息进去的 (配合Jpush极光)
- 极光推送Jpush之RestAPI使用实例
- JPush极光推送Java服务器端实例
- JPush极光推送Java服务器端实例
- Android开发--判断网络是否连接
- python 通过logging写入日志到文件和控制台
- VC界面开发组件Xtreme Toolkit Pro全新发布v17.0.0|附下载
- Android Notification
- PAPER
- jpush app 消息推送项目 实例
- ios学习历程记录
- 批量添加删除用户方法三
- git 自动补全 (git auto completion)
- Vector,ArrayList,LinkedList 的区别是什么?
- Android实例-路径信息及文件和文件夹的操作(XE8+小米2)
- UIWebView头文件学习
- hibenate 主键生成策略
- 莫队算法