aspose file tools*
The moose likes iOS and the fly likes Problem sending Apple Push Notification using Java and REST Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » iOS
Bookmark "Problem sending Apple Push Notification using Java and REST" Watch "Problem sending Apple Push Notification using Java and REST" New topic
Author

Problem sending Apple Push Notification using Java and REST

Michael K. Wilson
Ranch Hand

Joined: Apr 23, 2008
Posts: 45
Hello there,

Am using the javapns library on Google Code to send an Apple Push Notification through a REST based web service...

Here are the steps that I have completed:

iPhone Developer Program Portal (IDPP)
:

(1) Created the App ID and APNS based SSL Certificate and Keys.

(2) Created and installed the provisioning profile.

(3) Installed the SSL Certificate and Key on the server.

(4) Set up my iPhone app to register for remote notifications.

XCode
:

Was able to obtain my device token when I built and deployed my app onto my device.

As soon as my iPhone app deployed, the dialog came up on my iPhone indicating that my app would like to send push notifications and also asked for permission to allow them.

When I invoked my web service, through my Log4J statements, I was able to see that my REST based web service was indeed invoked but I never received a push notification on my iPhone app!

ApnsManager class:



RESTful Web Service:



Now, when I deploy my app to my app server and open up a rest client and type in:

http: // localhost:8080/myapp/apns/send

The rest client returns this:

HTTP/1.1 200 OK


The following log messages are outputted to my console:



However, I don't receive the push notification on my app (residing on my iPhone)!

Am really stumped at this point...

What could I possibly be doing wrong?

Is it a problem with the way I set up my RESTful web service (sorry I am a newbie to REST)?

Would really appreciate it if someone could assist me with this...

Thank you for taking the time to read this...
Michael K. Wilson
Ranch Hand

Joined: Apr 23, 2008
Posts: 45
Discovered the solution! The generated device token string seemed too long.

My NSData to hex code was printing the wrong token (it should be 64 characters, before it was 155 characters).

Solution:


Now, I am receiving the notifications on my Device!

Happy programming to all!
 
Don't get me started about those stupid light bulbs.
 
subject: Problem sending Apple Push Notification using Java and REST