Java Aurora Push

Source: Internet
Author: User

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 = "" ;p rivate final static String Mastersecret = "";/** * Test method */public static void Main (string[] args) {//Send notification Jsend_notificati On ("0a139889879", "You have a new logistics 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. Should review 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 (P Latform.android_ios ())//Required push platform settings. Setaudience (Audience.registrationid (Registrationid)). Setnotification (Notifica     Tion.alert (Alert))/** * If the target platform for the IOS platform needs to be in options * through the apns_production field to develop the push environment. * True to push the production environment, False to push the development environment, or to push the production environment if the * fruit is not specified. SetOptions (Options.newbuilder (). Setapnsproduction (FAL SE). Build ()). build ();}}

Java Aurora Push

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.