0

I want to add push notification for my app. I googled an got the stuff running in test mode. I:

  • set up the certificate, provisioning profiles, everything
  • set up a live server
  • obtained my device code
  • used simplepush.php to send a push to my device

and voila; I got a push message. But now what?

I want to add my app to the App Store in a few days so how does this work in real life?

1) What else except the provisiong profile from developer to distribution (both for the app and push) and the server sandbox.push.apple.com to push.apple.com do I have to change? 2) To what device code do I send the push with simplepush.php? Do I need to save every single device code in a database somewhere and send it to every device code using a script (and Apple checking if that device really wants the push) or is apple taking care of it all and can I just send it to my own device code? Or something else? 3) ...?

Any clarification is greatly appreciated. Thanks in advance!

Eran
  • 387,369
  • 54
  • 702
  • 768
Jack33
  • 121
  • 1
  • 9

1 Answers1

0

You need to keep track of all the device tokens. If you send apple a push for your device alone that is the only device that will receive it. You also need to regularly connect to the apple feedback server to get a list of device tokens that are no longer valid.

Depending on your needs, and the scope of your project it may be worth looking at using a third-party push provider (such as urban airship) that will handle all of this for you, especially if you are just wanting to "broadcast" notifications which I assume is the case based on your question.

Mark Willsher
  • 666
  • 7
  • 14
  • I want to do this myself, for various reasons (most notably wanting to know how it works). So I store every device token I get in a database I set up and send them a push whenever I want. If a user disabled push since I stored it in my database, will it still get it? Is that why I need to connect with Apple's servers? For a check who still wants those push messages? – Jack33 Apr 07 '12 at 17:00
  • A) Yes you store every device token yourself. B) You should provide settings for your app allowing a user to turn push off for your app etc... and store that info yourself - on the device they can disable push popups, badges etc... when your app isnlt in the forground, but will still get notifications when your app is running. C) The feedback services will give you a list of devices that have repeated delivery failures (generally because the app has been uninstalled) - this is so you can stop spamming apple with pushes that go nowhere. D) apple docs are here: http://goo.gl/PFnD2 – Mark Willsher Apr 07 '12 at 17:26
  • A) OK B) In this case I'll send a push whenever a news item has been added. There are no further actions in the app itself, so there's no need to build this. C) I see, that seems logical to me. Thanks a lot for your info! Last question: do you know a nice tutorial, preferably with code, about connecting to Apple's servers and getting the useless device tokens? – Jack33 Apr 07 '12 at 17:38
  • I don't, but you might start here: http://stackoverflow.com/questions/1278834/php-technique-to-query-the-apns-feedback-server – Mark Willsher Apr 07 '12 at 17:47