JPush极光推送服务器端API

来源:互联网 发布:网址推广联盟 乐乎 编辑:程序博客网 时间:2024/06/07 10:18

jpush初始化:

1、对android和ios设备发送

JPushClient jpush = new JPushClient(masterSecret, appKey);

2、对android和ios设备发送,同时指定离线消息保存时间

JPushClient jpush = new JPushClient(masterSecret, appKey, timeToLive);

3、指定某种设备发送

JPushClient jpush = new JPushClient(masterSecret, appKey, DeviceEnum.Android);

4、指定某种设备发送,同时指定离线消息保存时间

JPushClient jpush = new JPushClient(masterSecret, appKey, timeToLive, DeviceEnum.IOS);

参数说明:

这里写图片描述

发送消息:

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

代码示例:

1、发送带IMEI的通知

JPushClient jpush = new JPushClient(masterSecret, appKey);//jpush.setEnableSSL(true);int sendNo = 1;String imei = "";String msgTitle = "";String msgContent = "";MessageResult msgResult = jpush.sendNotificationWithImei(sendNo, imei, msgTitle, msgContent);if (null != msgResult) {    if (msgResult.getErrcode() == ErrorCodeEnum.NOERROR.value()) {        System.out.println("发送成功, sendNo=" + msgResult.getSendno());    } else {        System.out.println("发送失败, 错误代码=" + msgResult.getErrcode() + ", 错误消息=" + msgResult.getErrmsg());    }} else {    System.out.println("无法获取数据");}

2、IOS设置通知铃声及badge

JPushClient jpush = new JPushClient(masterSecret, appKey);Map<String, Object> extra = new HashMap<String, Object>();IOSExtra iosExtra = new IOSExtra(1, "Windows_Logon_Sound.wav");//badge and soundextra.put("ios", iosExtra);MessageResult msgResult = jpush.sendNotificationWithAppKey(sendNo, msgTitle, msgContent, 0, extra);
原创粉丝点击