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
2.
add apns.jar, commons-lang-2.0.jar files into your build path
the following is the sample program
try{
PayLoad simplePayLoad = new PayLoad();
simplePayLoad.addAlert("My alert message");
simplePayLoad.addBadge(1);
simplePayLoad.addSound("default");
PushNotificationManager.getInstance().addDevice("jijo's iPhone","give device token get from didRegisterForRemoteNotificationsWithDeviceToken delegate");
Device client = PushNotificationManager.getInstance().getDevice("jijo's iPhone");
PushNotificationManager.getInstance().initializeConnection("gateway.sandbox.push.apple.com", 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){
e.printStackTrace();
}
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) .
To send notification from java, I found this
1. download apns.jar from the above link
2.
add apns.jar, commons-lang-2.0.jar files into your build path
the following is the sample program
try{
PayLoad simplePayLoad = new PayLoad();
simplePayLoad.addAlert("My alert message");
simplePayLoad.addBadge(1);
simplePayLoad.addSound("default");
PushNotificationManager.getInstance().addDevice("jijo's iPhone","give device token get from didRegisterForRemoteNotificationsWithDeviceToken delegate");
Device client = PushNotificationManager.getInstance().getDevice("jijo's iPhone");
PushNotificationManager.getInstance().initializeConnection("gateway.sandbox.push.apple.com", 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){
e.printStackTrace();
}
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) .
is this worked successfully for U ?
ReplyDeleteIm getting the exception that there no trusted certificate like that.
you should remove your old profile.
ReplyDeletecreate a new profile from the push enabled application. and install/use this new profile
oh !.. you are talking about the issues with server side right..
ReplyDeleteI will edit the above post to show how to get the proper certificate file from keychain
David I want to do the broadcasting with
ReplyDeleteJava 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....