Jpush Aurora Push Java server-side API

Source: Internet
Author: User

Rookie Spring Jpush Aurora push Java server-side 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);
Parameter name parameter Type Options Content Description
Mastersecret
String Have to Mastersecret generated when registering an app on the portal
AppKey String Have to AppKey generated when registering an app on the portal
TimeToLive Long Options available

The length of time the offline message was saved. seconds in the unit. Supports up to 10 days (864,000 seconds).
0 indicates that the message is not saved offline. That is, the user is issued immediately online, the current non-online users will not receive this message.
This parameter is not set to default, and the default is to save 1 days of offline messages (86,400 seconds).

Deviceenum Enum Options available The specified device.
Optional values: deviceenum.android, Deviceenum.ios.
Do not fill in or null values to support both Android and IOS.
Send Message

Jpushclient Public methods

Method Name parameter list (required) Method Description
Setenablessl Boolean Enablessl (True to use SSL, default to SSL not used) Whether to start an SSL secure connection

Sendnotificationwithimei

int Sendno (send number),
String Imei (Imei string),
String msgtitle (Message title/notification header),
String msgcontent (message content/notification content)
Send a notification with IMEI
Sendnotificationwithimei int Sendno,
String IMEI,
String Msgtitle,
String Msgcontent,
int Builderid (custom notification bar style ID),
Map<string, Object>extra (affiliated information)
Custom Notification bar (no fill 0)
and delivery of ancillary information

Sendcustommessagewithimei

int Sendno,
String IMEI,
String Msgtitle,
String msgcontent
Send a message with IMEI
Sendcustommessagewithimei int Sendno,
String IMEI,
String Msgtitle,
String Msgcontent,
String msgcontenttype (Message content type, returned as-is),
Map<string, Object> Extra
User-defined message type,
and delivery of ancillary information

Sendnotificationwithtag

int Sendno,
String tag (tag string),
String Msgtitle,
String msgcontent
Send a notification with tag
Sendnotificationwithtag int Sendno,
String tag,
String Msgtitle,
String Msgcontent,
int Builderid,
Map<string, Object>extra
Custom Notification bar (no fill 0)
and delivery of ancillary information

Sendcustommessagewithtag

int Sendno,
String tag,
String Msgtitle,
String msgcontent
Send a message with tag
Sendcustommessagewithtag int Sendno,
String tag,
String Msgtitle,
String Msgcontent,
String Msgcontenttype,
Map<string, Object> Extra
User-defined message type,
and delivery of ancillary information

Sendnotificationwithalias

int Sendno,
String alias (alias string),
String Msgtitle,
String msgcontent
Send a notification with Alias
Sendnotificationwithalias int Sendno,
String alias (alias string),
String Msgtitle,
String Msgcontent,
int Builderid,
Map<string, Object>extra
Custom Notification bar (no fill 0)
and delivery of ancillary information

Sendcustommessagewithalias

int Sendno,
String alias,
String Msgtitle,
String msgcontent
Send a message with alias
Sendcustommessagewithalias int Sendno,
String alias,
String Msgtitle,
String Msgcontent,
String Msgcontenttype,
Map<string, Object> Extra
User-defined message type,
and delivery of ancillary information

Sendnotificationwithappkey

int Sendno,
String Msgtitle,
String msgcontent
Send notifications to all users of Appkey
Sendnotificationwithappkey int Sendno,
String Msgtitle,
String Msgcontent,
int Builderid,
Map<string, Object>extra
Custom Notification bar (no fill 0)
and delivery of ancillary information

Sendcustommessagewithappkey

int Sendno,
String Msgtitle,
String msgcontent
Send a message with Appkey
Sendcustommessagewithappkey int Sendno,
String Msgtitle,
String Msgcontent,
String Msgcontenttype,
Map<string, Object> Extra
User-defined message type,
and delivery of ancillary information

code example code example-sending a notification with 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("无法获取数据");}
code example-ios setting notification ringtones and 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);
Messageresult class
Public Methods method Use

Getsendno

After the message is sent successfully, the SENDNO is returned as it was transmitted by the client

Geterrcode

Error code, Code definition reference Errorcodeenum
Geterrmsg Returns the description of the error message
ErrorCode class Error code-errorcodeenum 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;      } }

Jpush Aurora Push Java server-side API

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.