Java Server calls jpush Aurora push API to push notification messages

Source: Internet
Author: User

Calling the jpush API has been described in detail on the official website. I just wrote a small demo for testing!

Register an account on the official website of Aurora push to obtainApplication ID (Ppkey),API
Mastersecret,
APK application. Install and run the APK on your mobile phone,

Background test code:

Package COM. zensoftware. test; import CN. jpush. API. errorcodeenum; import CN. jpush. API. jpushclient; import CN. jpush. API. messageresult; public class testpush {jpushclient jpush = new jpushclient (master, appkey); // modify the two parameters for your registered int sendno = 108; // in actual business, it is recommended that sendno be an auto-increment number that can be processed by your own business. String IMEI = "IMEI code of the mobile phone"; string msgtitle = ""; string msgcontent = "this is an example of Aurora push! "; Public int max = integer. max_value; Public int min = max/2; messageresult msgresult = NULL; Public void pushmsg () {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 get data") ;}} public int getrandomsendno () {return (INT) (min + math. random () * (max-min);} public static void main (string [] RGS) {testpush test = new testpush (); test. pushmsg (); system. Out. println ("----- push completed! ");}}

Ensure that the mobile phone network is smooth and the background code is running correctly to see the effect!


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.