1.enable loggingjavapns uses the log4j, to ensure that log is working properly, add the following code during use:import org.apache.log4j.*; ...try { basicconfigurator.configure (); ... } catch (exception e) { //do Added in Sth. }log4j.properties: log4j.logger.javapns=debug2.sandbox (development environment) to production (product environment) Migration Considerations The device tokens of the two set of environments is different and needs to be updated device tokens after the migration. two sets of environment certificates is also different, need to update the certificate. Repair sandbox environment work, production push failed solution. http://www.techjini.com/blog/ HOW-WE-FIXED-PRODUCTION-PUSH-NOTIFICATIONS-NOT-WORKING-WHILE-SANDBOX-WORKS/3. Customizing message content Public void send (List<device> devices, object keystore, string password, boolean production) { /* Build a blank payload to customize */ pushnotificationpayload Payload = pushnotificationpayload.complex (); /* Customize the payload */ payload.addalert ("Hello world! "); //apple Prompt Message payload.addcustomdictionary ("WebView", "http:/ /www.womai.com "); //hidden parameters for some custom operations, such as automatic jumps. payload.addcustomdictionary ("Mykey2", 2); // etc. /* Push your custom payload */ List<PushedNotification> notifications = Push.payload (payload, keystore, password, production, devices); }4. Multi-threaded bulk send push message public void send (list<device> devices, object keystore, string password, boolean production) { /* Prepare a simple payload to push */ PushNotificationPayload payload = Pushnotificationpayload.alert ("hello world!"); /* Decide how many threads you Want to create and use */ int threads = 30; /* Start threads, Wait for them, and get a list of all pushed notifications */ List<PushedNotification> Notifications = push.payload (Payload, keystore, password, production, threads, devices); note: The above multithreaded methods are returned after all threads have executed, and if you do not want to wait for the thread to finish, you can create a separate thread: (example: new thread () {public void run () {...}. Start ();). 5. Create a message queue (connection pool) a queue is a set of multi-threaded connections that connect APNs, and the queue dynamically distributes messages to different threads. public void send (String token, object keystore, string password , boolean production) { /* prepare a simple payload to push */ Pushnotificationpayload payload = pushnotificationpayload.alert ("Hello World!"); /* Decide how many threads you want your queue to use */ int Threads = 30; /* create the queue */ &nBsp; pushqueue queue = push.queue (keystore, password, Production, threads); /* start the queue (all threads and connections and initiated) */ queue.start (); /* add a notification for the queue to push */ queue.add (Payload, token); Note: If you do not pass Queue.start Message Queuing, the queue will be called the first time queue.add When you start 5. It is recommended to turn on the Enhancednotificationformat by default, it is recommended to turn on, the payload object can get more details of push message, such as execution status, expiration time, etc. 6. Push status (Error) management 1) error-response packets Pushednotification.issuccessful () //determine if the push succeeds pushednotification.getexception () //Get detailed error information, the system error will not be thrown to ensure the normal operation of multithreading, error messages will be recorded to PushednoThe tification. Example code: list<pushednotification> notifications = push.alert (" hello world! ", "KEYSTORE.P12", "Keystore_password", false, devices); for (pushednotification notification : Notifications) { if (nOtification.issuccessful ()) { /* Apple accepted the notification and should deliver it */ System.out.println ("push notification sent successfully to: " + notification.GetDevice (). GetToken ()); /* still need to query the Feedback Service regularly */ } else { String Invalidtoken = notification.getdevice (). GetToken (); /* add code here to remove invalidToken from your database */ /* find out more about what the problem was */ exception theproblem = notification.getexception (); theproblem.printstacktrace (); /* if the problem was an error-response packet returned by Apple, get it Responsepacket theerrorresponse = notification.getresponse (); if (Theerrorresponse != null) { system.out.println ( Theerrorresponse.getmessage ()); } } &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;}&NBSP;&NBSP;&NBSP;&NBSP;2) Feedback Service public class FeedbackTest { public Static void main (String[] args) { list<device > inactivedevices = push.feedback ("Keystore.p12", "Keystore_password", false); /* remove inactive devices from your own list of devices */ } remarks:sandbox feedback service not listing device After app is reMoved delays involving the feedback service
Java Javapns iOS push-based configuration