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.
Setting up Push Notifications in iOS. Go back to the iOS project you created earlier and select the main target. Under the Signing & Capabilities tab, click on the + Capability button, then select Push Notifications. This will enable your app to receive push notifications from OneSignal.
Web Push for Safari will use the same Apple notification service that powers Native Push on all iOS devices. New end-point URLs will send notifications from subdomains of push.apple.com.
Turn on notifications for Android devicesTap More on the bottom navigation bar and select Settings. Tap Turn on notifications. Tap Notifications. Tap Show notifications.
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.
To send a notification, you can do it in two steps:
Setup the connection
ApnsService service =
APNS.newService()
.withCert("/path/to/certificate.p12", "MyCertPassword")
.withSandboxDestination()
.build();
Create and send the message
String payload = APNS.newPayload().alertBody("Can't be simpler than this!").build();
String token = "fedfbcfb....";
service.push(token, payload);
[...]
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
http://www.ilime.com
Edit As of July 1, 2011, the iLime API has been discontinued as a public service.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With