Search code examples
iosnotificationspush-notificationbackground-process

Can push notifications be used to run code without notifying user?


I have an app which needs to communicate with a server (to refresh it's data) once every 24 hours. This needs to happen even if the app is not open, nor in the background.

Ideally what I'd like is:

  • Every 24 hours, my server sends a push notification to iPad
  • This wakes up the app, and runs the code necessary to refresh the data
  • The notification is then discarded

Is any of this possible?
Is the app only woken up AFTER the user clicks on the notification? Or can I run some code before showing the notification? Can I even discard the notification message?

If Push notifications are not the right way to do this, what is???

Thanks guys!


Solution

  • With release of iOS 7 this is finally possible using Remote/Silent notifications. They work same as Push notifications but instead of alerting the user immediately they can fire up background fetch mode and upload/download new content.

    Here is simple tutorial:http://www.objc.io/issue-5/multitasking.html