Creating iPhone app that runs at startup and every X minutes

I have written an Android app and am now porting to iPhone. The Android version uses a broadcast receiver to get notified when the device is rebooted, and at that time it does a background synchronization with my web server. Then it uses alarm manager to schedule another notification in X minutes (where X is set by the user in my app settings), which just does another background sync.

Is this possible on the iPhone, and what APIs should I be looking at? I'm programming with the latest XCode version (4.5 I think) on OSX Mountain Lion, and will be targeting iPhone mostly but also want something that works on iPad. iPhone 4 (iOS 5.0) and above would be fine as most of my customers have newer devices.

If not obvious, I'm very new to XCode, Mac OS, iOS, and Objective-C (still trying to use Alt-TAB to switch windows).

Answers


This isn't possible on the iPhone — it's incompatible with Apple's multitasking model. If it helps understand motivation, Apple's basic position is that allowing apps unfettered background execution privileges would be a very bad idea from a battery-life point of view since there's no practical way to ensure that such apps are well written.

You'll need to synchronise on launch and use push notifications if you want to make the user aware of something if they're not currently online. There are some special categories of app that can be awoken for strictly limited time periods upon certain events (like a change in location, receiving a VoIP call or playing audio content) but the list is strict and confined. See this document, in particular paying attention to the stuff from 'Implementing Long-Running Background Tasks' onward.


Need Your Help

Java workaround for subclass forced to call super() in constructor?

java subclass super superclass

I am editing a program that uses a RandomAccessFile object, and I want to come up with my own RandomAccessFile class that uses a different source for the data other than a file object (it's an Amazon

Drupal - Backup and Migrate Module MySQL Error

php mysql drupal drupal-7

I recently tried backing up my production site and uploading the content to a barbones drupal installation running locally. When I do the restore I get the following error about 15 seconds into the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.