JPush极光推送服务器端API

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 sound
extra.put("ios", iosExtra);

MessageResult msgResult = jpush.sendNotificationWithAppKey(sendNo, msgTitle, msgContent, 0, extra);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值