Jpush Aurora Push Java server-side API

Source: Internet
Author: User

Transferred from: http://www.cnblogs.com/zhanghaoh/archive/2013/02/20/2919282.html
// Send to Android and iOS devices New  //  Send to Android and iOS devices while specifying offline message save time new//  Specify some kind of device to send New  //  Specify some kind of device to send, and specify the offline message save time 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
 PackageCn.jpush.api; Public enumErrorcodeenum {//no error, send successNoError (0),     //System Internal ErrorSystemerror (10),     //GET request not supportedNotsupportgetmethod (1001),     //Missing Required ParametersMissingrequiredparameters (1002),     //parameter value is not validInvalidparameter (1003),     //validation FailedValidatefailed (1004),     //The message body is too largeDatatoobig (1005),     //The IMEI is illegal .Invalidimei (1007),     //Appkey is illegal .Invalidappkey (1008),     //msg_content is illegal .Invalidmsgcontent (1010),     //no push targets meet the criteriaInvalidpush (1011),     //iOS does not support custom messagesCustommessgaenotsupportios (1012); Private Final intvalue; PrivateErrorcodeenum (Final intvalue) {         This. Value =value; }      Public intvalue () {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.