Take the 2-minute tour ×

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!

share|improve this question
add comment

3 Answers

up vote 0 down vote accepted

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

share|improve this answer
add comment

This is only possible if your application is a Newsstand App, if it is, you can send a push notification with content-available: true once every 24 hours.

If it is not a newsstand app, you can instead use GPS fences to run code. It is allowed to let the user set up GPS fences if they want the app to update when the user comes close to an area (ie. their home / work). This will wake the app and you can run the background download then. Instapaper for example does this.

share|improve this answer
Thanks HN. So to confirm, if I send a push notification, no code will be run by the app until the user clicks the notification message? –  theDuncs Aug 8 '12 at 9:59
If it's a newsstand app, you can run code without any user intervention. You can read about it here: developer.apple.com/library/ios/#documentation/StoreKit/… –  Hampus Nilsson Aug 8 '12 at 10:02
It's not a Newsstand app, unfortunately. –  theDuncs Aug 8 '12 at 10:18
Then you need to use the GPS solution. Other than that there is no way to do it. –  Hampus Nilsson Aug 8 '12 at 10:27
OK. Thanks a lot. I'm going to leave the question open a little longer to see if anyone else has any other feedback, but will mark it as answered by you if not. –  theDuncs Aug 8 '12 at 10:34
add comment

if the period is always going to be 24 hours you can use local notifications instead of push notifications.

your app won't be able to run any code unless the user open the push notification, push notifications are handled by the OS and your app have no control on them while it's not active or in the background you should take a look at the push notification programming guide

an alternative way to accomplish what you are trying to do, is to get the data from the server every time the app is started and the last update happened 24 hrs earlier ,

  1. every time you contact the server save the date in NSUserDefault
  2. every time the user opens the app check if the last server contact happened before 24 hours then refresh data
share|improve this answer
Thanks ahmad. The problem with this approach is that (a) I don't want any user interaction (i.e. local notifications won't work) and (b) the app needs to sync BEFORE the app is opened up by the user (because the user typically uses the app where they have no internet connection). Thanks for the suggestions though. –  theDuncs Aug 8 '12 at 9:57
add comment

Your Answer


