41

I need to send push notifications to iOS devices, from my Java server, using Apple Push Notification Service (APNS)

I found two libraries to send APNS push notifications in Java:

  1. java-apns
  2. javapns

But both seem to be abandoned (or at least they have bugs and the last release is a year ago).

java-apns has lots of forks. Is there any updated fork of this library in active development? Are there any other better choices?

sabadow
  • 5,095
  • 3
  • 34
  • 51

8 Answers8

37

If anybody else is looking for an APNs library in Java, we at RelayRides just released Pushy (http://relayrides.github.io/pushy/). It does some things differently than the other two contenders (like async network IO), so it can send large numbers of messages really quickly. We actually use it in production, too, so it's actively maintained by our engineers. Enjoy!

EDIT: To be clear, Pushy is free and open-source (MIT license).

EDIT: Project has moved to https://github.com/jchambers/pushy

Reins
  • 1,109
  • 1
  • 17
  • 35
Jon Chambers
  • 644
  • 7
  • 14
  • Can Pushy be used under App Engine or will the lack of ability to create sockets prevent it's proper function? – James Courtney Jun 02 '14 at 18:23
  • I'm not really familiar with App Engine or its limitations, but if it restricts opening arbitrary network connections/sockets, I suspect it won't work. – Jon Chambers Jun 03 '14 at 18:59
  • Sorry, I think I remembered the limitation wrong here. The issue has more to do with restricting thread creation than opening sockets. I believe the latter is fine but handling async IO without additional threads is tough. I like the look of Pushy but I believe it uses additional threads in the library to handle responses from the APNS servers and I suspect these will break on App Engine. Has anyone tried this? – James Courtney Jun 06 '14 at 23:43
  • 1
    Regarding App Engine: opening a socket wouldn't be a problem but pushy uses nio classes that are restricted on App Engine. That is, it won't work on App Engine. :( Looks more awesome that any other APNS java library, though. – Zsolt Safrany Jul 29 '14 at 17:25
  • I've chosen Pushy mainly because it has a package in maven. I've a Java web app running on jboss8 (wildfly) server, and I was surprised how easy it was to implement the push notification functionality with pushy, It worked on the first go with no exceptions. I was extremely happy with the choice. – simonC Sep 05 '14 at 07:24
  • I am unable to use Pushy. I get `ClassNotFoundException: org.eclipse.jetty.alpn.ALPN$Provider` – Alan May 25 '16 at 23:25
  • I get this error with `pushy` which has made me look for alternatives. https://stackoverflow.com/questions/44802101/java-lang-noclassdeffounderror-io-netty-handler-ssl-sslcontextbuilder – Richard Jun 28 '17 at 12:56
  • The project has moved to https://github.com/jchambers/pushy – 6006604 Nov 03 '20 at 12:27
9

After digging around for a while, I could only find those two libraries you mentioned so I looked at some of the most recent forks on the java-apns GitHub page and the most recent one I could find was done by a user under the name "froh42". His fork is located here [dead]. The latest commit was 4 days ago, but I'm not sure if this person is actually adding to the repo's core functionality or not since it's very late and I'm too tired to check.

My suggestion would be, if you're going to use java-apns, to look at froh's repo and see if it checks out or not. If it doesn't, you can view the list of forks from the original java-apns repo here. Sorry I couldn't be of more help to you and good luck!

Note: Do not use any of your libraries since those are based on the Binary Provider API which will stop working from Nov. 2020!

Lonzak
  • 9,334
  • 5
  • 57
  • 88
stevenelberger
  • 1,368
  • 1
  • 10
  • 19
  • 2
    First at all, thanks for your answer. Before asking I reviewed all the forks of the library on GitHub. One of them is the one that you mentioned. So I probably start trying this one. – sabadow Jan 27 '13 at 20:48
  • 3
    For future references, that branch has been closed and it's rejoined to trunk. – giampaolo May 03 '13 at 21:00
  • 1
    @stevenelberger It looks the fork is gone. – johnnieb Jul 29 '20 at 20:57
4

I faced the same issue a few month back with a Java backend for one of our apps and after searching for libraries (Which in fact wasn't even a possible option on the Google App Engine) I found Urban Airship.

Urban Airship is a middle man between your backend and the various push notification services (it does support APNS, but as well android / blackberry / Win). You just need to configure your Push service on their platform, implement a REST call to one of their endpoint and done!

They have free plan starting with 1 Million (1.000.000) notifications / month.

Really good service so far and it's giving us the ability to quickly scale to other push services without having to implement specific code on our server side.

sabadow
  • 5,095
  • 3
  • 34
  • 51
Eric Genet
  • 1,260
  • 1
  • 9
  • 19
3

Looks like java-apns is being updated. Last commit was 1 month ago...

https://github.com/notnoop/java-apns

I haven't used it yet but seems at least the project is not dead.

Update in 2020: The project is dead and is based on deprecated API which will stop working in Nov. 2020.

Lonzak
  • 9,334
  • 5
  • 57
  • 88
Nighthawk
  • 125
  • 1
  • 9
  • First attempt at it and it works fine...probably either gonna use this or JavaPNS. Not sure yet! – Cameron Askew Aug 07 '14 at 23:50
  • which Java mail file to run in order to send Apple Push Notifications? Where to give Device Token and cert.12 file in this code ? Please help ASAP –  Jun 10 '15 at 13:07
2

Finally I decide to use JavaPNS (https://code.google.com/p/javapns/) on my project, is easy to use and meets my requirements.

But I recently found a new project that looks very promising and I'm planning to use in a near future.

Inside of the AeroGear project there are several libraries. One of them is the AeroGear UnifiedPush Server with support to Apple’s APNs, Google Cloud Messaging and Mozilla’s Simple Push.

Also has client libraries (iOS, Android) to easy integration with server:

Also has other some cool features like, Administration console, Java Sender client API, Rest API, ...

Hope it helps to someone else.

sabadow
  • 5,095
  • 3
  • 34
  • 51
  • 1
    Did you get to use AeroGear on your projects? I'm strugling to find a way to use it as a push notification abstraction library, as oposed to a full blown server. – Bruno Flávio Feb 21 '14 at 09:27
2

I use javapns, so far I didn't see issues (My project is still on development progress); But I saw the project wasn't updated since 2 years ago. and java-apns is keeping update, I will have a try.

Updated my answer, I started to use pushy for APN since 3 month ago, it really has better performance. Now I suggest to use pushy.

Stony
  • 3,541
  • 3
  • 17
  • 23
1

I would not recomment JavaPns if you intend to use it's queue mode because you want to send many messages at a time. There's a really nasty Bug which makes you lose push notifications, but the library says, everything was sent.

MrJ
  • 123
  • 6
1

This one is very good i have used it

https://github.com/notnoop/java-apns

I have also tried javaapns

https://code.google.com/p/javapns/

but some how it was not worked for me. It was giving me success = true on sending notification but my device was not able to receive it.