How do you set up javapns (push notifications for iOS)?

14,011

Solution 1

I have used Java APNS in the past. It has a BSD License and did a perfect job and was quite easy to use once the certificates were set up. All in all it is not a dead-simple task to set up Push notifications, but I usually got usable debug output if there was anything not quite working yet.

A good thing about this solution is that you can run it stand alone java -jar MyAPNSPusher and trigger it with some cron job or include the logic in some .war file. I also found that the library was quite lightweight and I guess you can also find it in a maven repo.

Example from the Readme.markdown

To send a notification, you can do it in two steps:

  1. Setup the connection

    ApnsService service =
        APNS.newService()
        .withCert("/path/to/certificate.p12", "MyCertPassword")
        .withSandboxDestination()
        .build();
    
  2. Create and send the message

    String payload = APNS.newPayload().alertBody("Can't be simpler than this!").build();
    String token = "fedfbcfb....";
    service.push(token, payload);
    

[...]

Alternatives

If hosting your own server solution is too cumbersome then you can fallback to a thirdparty service which might often be a good thing because hosting a server with such a service running on it is probably often underestimated. With those services you usually pay a tiny amount (fractions of a cent) for a push message. Two that I have come across are

Solution 2

JavaPNS is a java library used within your project. It can only be used to connect to the Apple Push Notification Servers, using the certificates that you create on the Apple Developer Tools Website.

So, if I'm reading your question properly, this is not a stand-alone program and probably not what you want.

If you are trying to send push notifications to Apple iOS devices, then this IS what you want, but you need to write the rest of your application first, then add this library to it.

Share:
14,011
user798719
Author by

user798719

Some questions may end up being dumb, but if I ask it, it's not dumb to me.

Updated on June 09, 2022

Comments

  • user798719
    user798719 almost 2 years

    I have had a look at the documentation / wiki for javapns. http://code.google.com/p/javapns/

    Unfortunately, what should be obvious is anything but obvious to me.

    How do I set up a working push notification server? As in, there's a .jar file, but I would appreciate more info than that. Do I need to run this in Tomcat? Is there a working example?'

    Thanks.