JPush极光推送Java服务器端API
JPush极光推送Java服务器端API
// 对android和ios设备发送
JPushClient jpush = new JPushClient(masterSecret, appKey);
// 对android和ios设备发送,同时指定离线消息保存时间
JPushClient jpush = new JPushClient(masterSecret, appKey, timeToLive);
// 指定某种设备发送
JPushClient jpush = new JPushClient(masterSecret, appKey, DeviceEnum.Android);
// 指定某种设备发送,并且指定离线消息保存时间
JPushClient jpush = new JPushClient(masterSecret, appKey, timeToLive, DeviceEnum.IOS);
|
参数名称 | 参数类型 | 选项 | 内容说明 |
---|---|---|---|
masterSecret |
String | 必须 | Portal上注册应用时生成的 masterSecret |
appKey | String | 必须 | Portal上注册应用时生成的 appKey |
timeToLive | long | 可选 |
保存离线消息的时长。秒为单位。最多支持10天(864000秒)。 |
DeviceEnum | Enum | 可选 |
指定的设备。 可选值:DeviceEnum.Android, DeviceEnum.IOS。 不填或者null值为同时支持 Android 与 iOS。 |
发送消息
JPushClient公共方法
方法名称 | 参数列表(必须) | 方法说明 |
---|---|---|
setEnableSSL | boolean enableSSL (true为使用ssl, 默认为不使用ssl) | 是否启动ssl安全连接 |
sendNotificationWithImei |
int sendNo(发送编号), String imei (IMEI字符串) , String msgTitle (消息标题/通知标题) , String msgContent (消息内容/通知内容) |
发送带IMEI的通知 |
sendNotificationWithImei |
int sendNo , String imei , String msgTitle , String msgContent , int builderId (自定义通知栏样式Id) , Map<String, Object>extra (附属信息) |
自定义通知栏(没有则填写0) 以及传递附属信息 |
sendCustomMessageWithImei |
int sendNo , String imei , String msgTitle , String msgContent |
发送带IMEI的消息 |
sendCustomMessageWithImei |
int sendNo , String imei , String msgTitle , String msgContent, String msgContentType (消息内容类型,原样返回), Map<String, Object> extra |
用户自定义消息类型, 以及传递附属信息 |
sendNotificationWithTag |
int sendNo , String tag (Tag字符串) , String msgTitle , String msgContent |
发送带Tag的通知 |
sendNotificationWithTag |
int sendNo , String tag , String msgTitle , String msgContent , int builderId , Map<String, Object>extra |
自定义通知栏(没有则填写0) 以及传递附属信息 |
sendCustomMessageWithTag |
int sendNo , String tag , String msgTitle , String msgContent |
发送带Tag的消息 |
sendCustomMessageWithTag |
int sendNo , String tag , String msgTitle , String msgContent , String msgContentType , Map<String, Object> extra |
用户自定义消息类型, 以及传递附属信息 |
sendNotificationWithAlias |
int sendNo , String alias (Alias字符串) , String msgTitle , String msgContent |
发送带Alias的通知 |
sendNotificationWithAlias |
int sendNo , String alias (Alias字符串) , String msgTitle , String msgContent , int builderId , Map<String, Object>extra |
自定义通知栏(没有则填写0) 以及传递附属信息 |
sendCustomMessageWithAlias |
int sendNo , String alias , String msgTitle , String msgContent |
发送带Alias的消息 |
sendCustomMessageWithAlias |
int sendNo , String alias , String msgTitle , String msgContent , String msgContentType , Map<String, Object> extra |
用户自定义消息类型, 以及传递附属信息 |
sendNotificationWithAppKey |
int sendNo , String msgTitle , String msgContent |
发送通知给AppKey的所有用户 |
sendNotificationWithAppKey |
int sendNo , String msgTitle , String msgContent , int builderId , Map<String, Object>extra |
自定义通知栏(没有则填写0) 以及传递附属信息 |
sendCustomMessageWithAppKey |
int sendNo , String msgTitle , String msgContent |
发送带AppKey的消息 |
sendCustomMessageWithAppKey |
int sendNo , String msgTitle , String msgContent , String msgContentType , Map<String, Object> extra |
用户自定义消息类型, 以及传递附属信息 |
代码示例
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( "无法获取数据" );
}
|
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);
|
MessageResult 类
公共方法 | 方法用途 |
---|---|
getSendno |
消息发送成功后,按客户端传输的sendNo原样返回 |
getErrcode |
错误代码,代码定义参考ErrorCodeEnum |
getErrmsg | 返回错误消息的描述 |
ErrorCode 类
package
cn.jpush.api;
public
enum
ErrorCodeEnum {
//没有错误,发送成功
NOERROR(
0
),
//系统内部错误
SystemError(
10
),
//不支持GET请求
NotSupportGetMethod(
1001
),
//缺少必须参数
MissingRequiredParameters(
1002
),
//参数值不合法
InvalidParameter(
1003
),
//验证失败
ValidateFailed(
1004
),
//消息体太大
DataTooBig(
1005
),
//IMEI不合法
InvalidIMEI(
1007
),
//appkey不合法
InvalidAppKey(
1008
),
//msg_content不合法
InvalidMsgContent(
1010
),
//没有满足条件的推送目标
InvalidPush(
1011
),
//IOS不支持自定义消息
CustomMessgaeNotSupportIOS(
1012
);
private
final
int
value;
private
ErrorCodeEnum(
final
int
value) {
this
.value = value;
}
public
int
value() {
return
this
.value;
}
}
转载于:https://www.cnblogs.com/widow/p/3966808.html
JPush极光推送Java服务器端API相关推荐
- 极光推送 java api_JPush极光推送Java服务器端API
方法名称参数列表(必须)方法说明 setEnableSSL boolean enableSSL (true为使用ssl, 默认为不使用ssl) 是否启动ssl安全连接 sendNotification ...
- 极光推送java服务器端_极光推送服务器端(JAVA)
准备工作:appkey和secret两个码.(在极光官网管理页面新增相关应用,就会获得对应的appkey和secret,这部分由移动端同事完成) 1.在pom文件下添加这个包: 2.添加工具类JPus ...
- jpush 极光推送 java
https://www.jianshu.com/p/22a4d630c01a http://blog.csdn.net/qq_35860097/article/details/75117323 转载于 ...
- **极光推送PHP服务器端推送移动设备消息(Jpush V2 api)
jpush.php 这是推送方法 用到curl发送请求 <?php /*** 极光推送php 服务器端* @author yalong sun* @Email <syl_ad@163. ...
- 用JPUSH极光推送实现服务端向安装了APP应用的手机推送消息(C#服务端接口)
这次公司要我们做一个功能,就是当用户成功注册以后,他登录以后要收到消息,当然这个消息是安装了我们的手机APP应用的手机咯. 极光推送的网站的网址是:https://www.jpush.cn/ 极光推送 ...
- Laravel 集成 JPush 极光推送指北
2019独角兽企业重金招聘Python工程师标准>>> 我是一个 Laravel 小白,我是一个 Laravel 小白,我是一个 Laravel 小白(默念三遍再往下读,如果非小白就 ...
- Android Jpush极光推送
平时我们开发手机客户端总是少不了与服务器进行交流,那当我们服务器数据有更新时候,客户端是怎么知道的呢,我们以前一般用两种方法: 1,客户端每隔一段时间向服务器发请求,检测数据是否发生变化,当发生变化的 ...
- php集成jpush教程,Laravel 集成 JPush 极光推送指北
我是一个 Laravel 小白,我是一个 Laravel 小白,我是一个 Laravel 小白(默念三遍再往下读,如果非小白就不用看了). Laravel 使用 Composer 来管理代码依赖.所以 ...
- 解决Android Studio配置JPush极光推送错误方案
1.在JPush极光推送官方下载 JPush SDK(jpush-android-release-2.1.7.zip) 2.解压下载好的压缩包解压并复制libs/jpush-android-2.1.7 ...
最新文章
- 360数据处理平台的架构演进及优化实践
- php mysql_query的的用法_PHPmysqli_query()函数定义与用法
- jQuery UI - Accordion 手风琴组件的使用
- anaconda的简单使用教程(虚拟环境安装)
- 分布式数据库基础:分布式数据库故障
- 一加7 Pro高清渲染图曝光:A+屏幕 超棒手感
- 爬取豆瓣评论连接mysql_Scrapy爬取豆瓣图书数据并写入MySQL
- ROS教程之读取激光雷达(sick_tim561)数据
- 通达信交易接口api_全市场股票量化交易
- 怎么在WPS计算机,电脑怎么把wps热点删了?电脑永久删除wps热点的方法
- 2020中国.NET开发者峰会近50场热点技术专题揭秘
- diskgenius克隆硬盘无法启动_用Diskgenius克隆分区到另一个磁盘上
- matlab计算加减乘除,matlab计算矩阵的加减乘除以及逆
- 网易游戏学院系列——书籍《游戏设计》【笔记】
- 解决上传SFTPorg.apache.commons.net.MalformedServerReplyException: Could not parse respon
- 经纬度批量转地址(保姆级教程)
- 编写configure.ac
- Amazon SES 邮件发送服务
- C++中的getline()函数
- CRI HITFM 88.7的网络电台
热门文章
- 开课吧Java课堂:如何运用equals( )和 equalsIgnoreCase( )
- JAVA中的枚举使用总结
- Android SQLite服务--创建、增删改查
- 交互设计[小插曲]--网站UI配色
- boost计算随机数和计算crc32简单示例 - jwybobo2007的专栏 - 博客频道 - CSDN.NET
- LeetCode 84. Largest Rectangle in Histogram
- 低字节+高字节+字地址+大端序+小端序全辨析
- 监控视频异常检测数据集整理
- 之前关于字符串拼接的错误修正
- mysql的安装与卸载