Clone this wiki locally
java-apns is a Java client for Apple’s Push Notification Service (APNS). The library aims to provide a highly scalable interface to the Apple server, while still being simple and modular.
The interface aims to require very minimal code to achieve the most common cases, but have it be reconfigurable so you can even use your own networking connections or JSON library if necessary.
- Easy to use, high performance APNS Service API
- Supports Apple Feedback service
- Easy to use with Apple’s certificates
- Easy to extend and reuse
- Easy to integrate with dependency injection frameworks
- Easy to setup custom notification payloads
- The library does not verify the correctness of deviceToken or the length of the sent notification message (needs to be less 255 in total)
- The Feedback servers use public certificates that are not verified by major SSL companies. Connecting to the Feedback servers would cause an Exception similar to the following:
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1611)
This is a known issue. The work around is to mark the public certificates as trusted by Java. The Downloads page contains
jssecacerts file, that can be placed in
jssecacerts is a keystore that contains the public certificate of Apple Feedback sandbox and production servers.
% wget http://code.google.com/p/java-use-examples/source/browse/trunk/src/com/aw/ad/util/InstallCert.java % javac InstallCert.java % java InstallCert feedback.sandbox.push.apple.com:2196 # [ ... press 1 when asked to ...] % java InstallCert feedback.push.apple.com:2196 # [ ... press 1 when asked to ...] % cp jssecacerts $JAVA_HOME/lib/security