My app runs constantly in kiosk mode. Once every 24 hours at a specific time I need to sync some data from core data to a web service.
I know how to do the sync piece but I don't know how to schedule the app to make the sync call at a specific time each day e.g. at 02:45 am.
Is it possible to do something like this when an app is running constantly?
A simple solution is just to set
NSTimer
to check current date every minute (or every second, for example). If the current date is greater then required, then fire the method and update the required date.Use Local Notifications. Here is a tutorial:http://www.icodeblog.com/2010/07/29/iphone-programming-tutorial-local-notifications/
Hope this helps u to start...
This as well:
Local Notifications
Background Tasks
Figured this out thanks to prompts from @lakesh. Posting solution in the case it helps somebody because I found NSNotification examples very difficult to understand at first.
In my main view controller I added the following method:
This sets a fire date for the notification of today at 02:45 am and recurs daily.
In viewDidLoad in my view controller I call the above method:
In the appdelegate I do the following: