web项目jpush配置
来源:互联网 发布:精易编程助手生成模块 编辑:程序博客网 时间:2024/06/05 11:03
1.在配置文件中配置参数
jpush.aunt.AppKey=a3935ef8a7744dee7b91e9f8jpush.aunt.MasterSecret=1fd647c7b0f73de17bcfba02jpush.apns.Production=true
2.java调用jpush
构造推送对象
public class JpushBeanDto implements Serializable { private static final long serialVersionUID = 2017475296277514323L; private Long messageId; // 订单ID private String type; // 通知类型 private String title; // 通知标题 private String alia; // 别名标记 private Set<String> tagValues = new HashSet<String>(); // 标签标记 private Map<String, String> extras = new HashMap<String, String>(); // 推送的数据信息,用于前后台交互 private String alert; // 推送消息的内容
转发层调用业务层
// 推送阿姨端jpush消息 @Scheduled(cron = "0/5 * * * * ?") public void pushAuntMessage() { jpushService.pushAuntMessage(); }
业务层注入参数
@Value("${jpush.aunt.AppKey}") private String auntAppKey; @Value("${jpush.aunt.MasterSecret}") private String auntAppSecret; @Value("${jpush.apns.Production}") private String isProduction; private JPushClient auntJpushClient;
构造jpush bean
private JpushBeanDto convertMessage2JpushBean(MessageEntity message) { String type = message.getType(); JpushBeanDto jpushBeanDto = new JpushBeanDto(); jpushBeanDto.setMessageId(message.getId()); jpushBeanDto.setAlia("employee_new_" + message.getObjectId().toString()); jpushBeanDto.setType(type); jpushBeanDto.setTitle(message.getTitle()); jpushBeanDto.setAlert(message.getContent()); // 设置交互信息 jpushBeanDto.getExtras().put("messageId", jpushBeanDto.getMessageId().toString()); jpushBeanDto.getExtras().put("type", type); if (MessageTypeEnum.AUNT_BILL_MESSAGE.getKey().equals(type)) { jpushBeanDto.getExtras().put("orderId", parseString2Map(message.getParams()).get("orderId")); } return jpushBeanDto; }
构造 pushPayload对象
pushPayload = pushAuntNotificationByTag(jpushBean); . . . private PushPayload pushAuntNotificationByTag(JpushBeanDto jpushBean) { Platform platform = Platform.all(); Audience audience = Audience.tag(jpushBean.getTagValues()); Notification notification = Notification.newBuilder().setAlert(jpushBean.getAlert()) .addPlatformNotification(AndroidNotification.newBuilder().setTitle(jpushBean.getTitle()).addExtras(jpushBean.getExtras()).build()).build(); Options options = Options.newBuilder().setApnsProduction(Boolean.valueOf(isProduction)).build(); return buildPushObject(platform, audience, notification, null, options); }
构造JpushClient
private JPushClient getAuntJPushClient() { if (auntJpushClient == null) { synchronized (JpushService.class) { if (auntJpushClient == null) { auntJpushClient = new JPushClient(auntAppSecret, auntAppKey); } } } return auntJpushClient; }
推送信息
auntJpushClient.sendPush(pushPayload);
0 0
- web项目jpush配置
- 极光推送Jpush配置步骤
- maven配置web项目
- web 项目配置详解
- 配置web项目
- web项目短信配置
- web项目配置https
- Eclipse配置Web项目
- web项目配置
- web项目配置方式
- web项目配置log4j
- Jpush
- jpush
- jpush
- JPush
- JPush
- jpush
- jpush app 消息推送项目 实例
- thinkphp-ajax异步验证之ajaxReturn的使用-方法二
- 梯度下降法(一)入门
- 7、Eclipse下的Java反编译插件,查看源代码不再困难
- 动手写自己的cuda遇到的问题1
- Fragment跳转问题
- web项目jpush配置
- ceilometer监控源码分析之任务队列
- extjs的Ext.define()函数的用法以及注意点。
- 「视频直播技术详解」系列之四:推流和传输
- android之Broadcast Receiver详解
- 堆&优先级队列
- java多线程读取多个文件 导入数据库
- 一点思考-遇见开复
- 如何把React Native嵌入到原生android应用中