Saturday, April 28, 2012

Java : Apple Push Notification Server Side Coding

JavaPNS is a Java library to send notifications through the Apple Push Notification Service to iOS devices. Using JavaPNS, we can send Push notification in a single line of code.

For further details, refer site :
The Apple Push Notification Service is a service created by Apple Inc. 
iOS apps can provide three types of notifications:
  • Sounds: Plays an audible alert
  • Alerts/Banners: Displays an alert or banner on the screen
  • Badges: Displays an image or number on the application icon
 Before sending a notification from server, we need to have the following.
  1. Device Token of the device (IPhone/IPod).
  2. Private Key created from certificate.
  3. Have a password of the private key created.
Note: If the private key is not proper, SSLHandshakeException occurs

For Eg:
Java Code looks like
Push.alert(message, keystore, password, production, devices)

Push.alert("Hello World!", "keystore.p12", "keystore_password", false, "Your token");
message : Content to pass
keystore : Private key
password : Private key password
producation : If true, production else sandbox
devices : one or more device token, device token length is 64 digits. The device token is analogous to a phone number; it contains information that enables APNs to locate the device on which the client application is installed.

To run the server code, required jar files list

Thanks for reading :).
Whether this post is helpful?
Please leave a comment.


  1. Hi - I am following tutorial from (send push notification to iOS device) and I used class to send notifications using DeviceId, cert.p12 and password, but I don't see any error / exceptions coming or notifications coming. Could you please let me know what the problem is ?

  2. Hey - Thank you. Could you please let me know how we can use callback?


    1. Have a look in