开发者

from where we send json payload when using APNs?

i want to know that when we want to use push notification service.From where we send json payload, from our app or it may be generated on server? if it has开发者_高级运维 to be sent from our app then how do we send json payload+device token to our own web server?


It can't be sent from your app. First off that would make no sense, if your app is running why would you have it send a push notification to itself.

Second, in order to communicate with the APNS servers you need a per app cert file to sign requests. You cannot distribute it without compromising the security of your applications push service.


Louis is absolutely right that you can't send messages from your phone, and his reasons are spot on. You'll definitely need to communicate to your own server, which will then send things on to Apple.

To send messages to your own server, look at ASIHTTPRequest - it's a fantastic package that makes it really easy to send HTTP requests.

On your server, you'll need to keep open a persistent connection to Apple's push service from your own servers and translate the JSON from the phone into a message to deliver to Apple.

There are at least two services out there that take care of the heavy lifting for you:

  • Urban Airship (full disclaimer, I work at Urban Airship)
  • iLime

You might want to look at one of these services to help you implement this. Again, I work at one, so take this with a huge grain of salt.

If you want to see some examples of how to use ASIHTTPRequest to send a device token to a server, you can look at our push sample application on bitbucket.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜