Java Aurora push

Source: Internet
Author: User

Java Aurora push

Note: need to go to the official website to download jpush-client-3.2.3.jar
/*** Aurora push tool class ** @ author why **/@ SuppressWarnings ("all") public class JPushAllUtil {private final static String appKey = ""; private final static String masterSecret = "";/*** Test Method */public static void main (String [] args) {// send a notification jSend_notification ("0a139889879 ", "You have a new logistic message _ 123 ");} /*** send notification ** @ param registrationId device ID * @ param alert push content */public static void jSend_notification (String registrationId, String alert) {JPushClient jpushClient = new JPushClient (masterSecret, appKey, 3); PushPayload payload = send_N (registrationId, alert); try {PushResult result = jpushClient. sendPush (payload); System. out. println (result);} catch (APIConnectionException e) {System. out. println (e);} catch (APIRequestException e) {System. out. println (e); System. out. println ("Error response from JPush server. shoshould re View and fix it. "+ e); System. out. println ("HTTP Status:" + e. getStatus (); System. out. println ("Error Code:" + e. getErrorCode (); System. out. println ("Error Message:" + e. getErrorMessage (); System. out. println ("Msg ID:" + e. getMsgId () ;}} public static PushPayload send_N (String registrationId, String alert) {return PushPayload. newBuilder (). setPlatform (Platform. android_ios () // push platform settings are required. setAudi Ence (Audience. registrationId (registrationId )). setNotification (Notification. alert (alert)/*** if the target platform is iOS, you need to use the apns_production field in options * to create a push environment. * True indicates the push production environment, and False indicates the push development environment. If * is not specified, the push production environment */. setOptions (Options. newBuilder (). setApnsProduction (false ). build ()). build ();}}

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.