Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 286
user798719 Avatar asked Feb 20 '12 07:02

user798719


People also ask

How do I set up push notifications on iOS?

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.

Do web push notifications work on iOS?

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.

How do I setup push notifications?

Turn on notifications for Android devicesTap More on the bottom navigation bar and select Settings. Tap Turn on notifications. Tap Notifications. Tap Show notifications.


2 Answers

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

  • http://www.ilime.com

    Edit As of July 1, 2011, the iLime API has been discontinued as a public service.

  • http://urbanairship.com/
like image 96
Besi Avatar answered Sep 18 '22 14:09

Besi


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.

like image 41
idbill Avatar answered Sep 17 '22 14:09

idbill