Thursday, November 5, 2009

APNS with java

I have tested push notification with pushmebaby sample program.. its worked fine.

To send notification from java, I found this
1. download apns.jar from the above link
add apns.jar, commons-lang-2.0.jar files into your build path
the following is the sample program
PayLoad simplePayLoad = new PayLoad();
simplePayLoad.addAlert("My alert message");
PushNotificationManager.getInstance().addDevice("jijo's iPhone","give device token get from didRegisterForRemoteNotificationsWithDeviceToken delegate");
Device client = PushNotificationManager.getInstance().getDevice("jijo's iPhone");
PushNotificationManager.getInstance().initializeConnection("", 2195, "C:/temp/APNSCertificates.p12", "paawordgivenwhenexport from keychain by click 'export 2 item' menu item", SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);
PushNotificationManager.getInstance().sendNotification(client, simplePayLoad);

}catch(Exception e){

I have also posted the same code as comments on that site

How to create APNSCertificates.p12 file from login keychain

After enable the push on your application from apple site, and install on your machine, you can see the same in keychain.

select the installed push ceritificate and key, right click and select the menu item "Export 2 items"

and give a name ( say: APNSCertificates.p12) .


  1. is this worked successfully for U ?
    Im getting the exception that there no trusted certificate like that.

  2. you should remove your old profile.
    create a new profile from the push enabled application. and install/use this new profile

  3. oh !.. you are talking about the issues with server side right..
    I will edit the above post to show how to get the proper certificate file from keychain

  4. David I want to do the broadcasting with
    Java APNS, in the java apns site and in your example message is sent to specific device only based on the device id. Is it possible ? I am not able to get the document on Java APNS to find that out and not able to dowload the source code to check it. can you please me in this regard....