JPush Aurora push Java Server API

Source: Internet
Author: User
// Send messages to android and ios devicesJPushClient jpush = new JPushClient(masterSecret, appKey); // Send messages to android and ios devices, and specify the offline message storage time.JPushClient jpush = new JPushClient(masterSecret, appKey, timeToLive); // Specify a device for sendingJPushClient jpush = new JPushClient(masterSecret, appKey, DeviceEnum.Android); // Specify a device to send and specify the offline message storage timeJPushClient jpush = new JPushClient(masterSecret, appKey, timeToLive, DeviceEnum.IOS);
Parameter Name Parameter type Option Description
masterSecret
String Required MasterSecret generated when an application is registered on the Portal
AppKey String Required AppKey generated when an application is registered on the Portal
TimeToLive Long Optional

The duration of offline messages. In seconds. Supports up to 10 days (864000 seconds ).
0 indicates that the message is not saved offline. That is, the user sends the message online immediately, and the current offline user will not receive the message.
If this parameter is not set, it indicates the default value. The default value is to save offline messages for one day (86400 seconds ).

DeviceEnum Enum Optional The specified device.
Value Options: DeviceEnum. Android and DeviceEnum. IOS.
If this parameter is left blank or null, both Android and iOS are supported.
Send message

JPushClient public Method

 

Method Name Parameter List (required) Method description
SetEnableSSL Boolean enableSSL (true indicates that ssl is used, and ssl is not used by default) Enable ssl secure connection?

SendNotificationWithImei

Int sendNo (sending number ),
String imei (IMEI String ),
String msgTitle (Message Title/notification title ),
String msgContent (message content/notification content)
Send notifications with IMEI
SendNotificationWithImei Int sendNo,
String imei,
String msgTitle,
String msgContent,
Int builderId (custom notification bar style Id ),
Map <String, Object> extra (ancillary information)
Custom notification bar (enter 0 if no notification bar exists)
And transmit ancillary information

SendCustomMessageWithImei

Int sendNo,
String imei,
String msgTitle,
String msgContent
Send messages with IMEI
SendCustomMessageWithImei Int sendNo,
String imei,
String msgTitle,
String msgContent,
String msgContentType (message content type, returned as is ),
Map <String, Object> extra
Custom message type,
And transmit ancillary information

SendNotificationWithTag

Int sendNo,
String tag (Tag String ),
String msgTitle,
String msgContent
Send a notification with a Tag
SendNotificationWithTag Int sendNo,
String tag,
String msgTitle,
String msgContent,
Int builderId,
Map <String, Object> extra
Custom notification bar (enter 0 if no notification bar exists)
And transmit ancillary information

SendCustomMessageWithTag

Int sendNo,
String tag,
String msgTitle,
String msgContent
Send a message with a Tag
SendCustomMessageWithTag
Int sendNo,
String tag,
String msgTitle,
String msgContent,
String msgContentType,
Map <String, Object> extra
Custom message type,
And transmit ancillary information

SendNotificationWithAlias

Int sendNo,
String alias (Alias String ),
String msgTitle,
String msgContent
Send notifications with Alias
SendNotificationWithAlias Int sendNo,
String alias (Alias String ),
String msgTitle,
String msgContent,
Int builderId,
Map <String, Object> extra
Custom notification bar (enter 0 if no notification bar exists)
And transmit ancillary information

SendCustomMessageWithAlias

Int sendNo,
String alias,
String msgTitle,
String msgContent
Send messages with Alias
SendCustomMessageWithAlias Int sendNo,
String alias,
String msgTitle,
String msgContent,
String msgContentType,
Map <String, Object> extra
Custom message type,
And transmit ancillary information

SendNotificationWithAppKey

Int sendNo,
String msgTitle,
String msgContent
All users who send notifications to AppKey
SendNotificationWithAppKey Int sendNo,
String msgTitle,
String msgContent,
Int builderId,
Map <String, Object> extra
Custom notification bar (enter 0 if no notification bar exists)
And transmit ancillary information

SendCustomMessageWithAppKey

Int sendNo,
String msgTitle,
String msgContent
Send a message with an AppKey
SendCustomMessageWithAppKey Int sendNo,
String msgTitle,
String msgContent,
String msgContentType,
Map <String, Object> extra
Custom message type,
And transmit ancillary information

 

Sample Code Code example-send notifications 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("Sent successfully, sendNo =" + msgResult.getSendno());    } else {        System.out.println("Failed to send, error code =" + msgResult.getErrcode() + ", Error message =" + msgResult.getErrmsg());    }} else {    System.out.println("Unable to obtain data");}
Code example-set notification ringtones and badge for IOS
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
Common Methods Usage

GetSendno

After the message is successfully sent, the message is returned as sendNo transmitted by the client.

GetErrcode

Error Code. For Code definition, see ErrorCodeEnum
GetErrmsg Description of the returned error message
ErrorCode class Error code-ErrorCodeEnum
package cn.jpush.api; public enum ErrorCodeEnum {         // No error. The message is sent successfully.    NOERROR(0),     // Internal system error    SystemError(10),     // The GET request is not supported.    NotSupportGetMethod(1001),     // Required parameters are missing    MissingRequiredParameters(1002),     // The parameter value is invalid.    InvalidParameter(1003),     // Verification Failed    ValidateFailed(1004),     // The message body is too large    DataTooBig(1005),     // Invalid IMEI    InvalidIMEI(1007),     // The appkey is invalid.    InvalidAppKey(1008),     // Msg_content is invalid    InvalidMsgContent(1010),     // The push target does not meet the conditions    InvalidPush(1011),     // Custom messages are not supported in IOS    CustomMessgaeNotSupportIOS(1012);     private final int value;    private ErrorCodeEnum(final int value) {        this.value = value;    }     public int value() {        return this.value;    }}

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.