Can an iPhone App take exclusive control or reliably record why it lost control
<p>I am trying to determine feasibility of certain features required in a (potential) project.  I am not (yet) looking for a how-to, just a can-do.  I apologize for any vagueness and ignorance: the former due to an NDA that makes Apple's NDA look like GPL, and the latter due to the fact that I have no iPhone or MAC experience.</p>

<p>I do have a solid understanding of objective-c and interface builder (going back to NextStep) and some PDA development experience, so I'll probably understand the answers, even if my questions are naive. I have done a bit of browsing, so I know some buzzwords.</p>

<p>I can't go into detail about the actual project, but I have come up with a lame analogy.</p>

<ul>
<li>a large number of users in the same room are asked to complete task(s) in the app (say a puzzle)</li>
<li>they are under supervision, but the monitor cannot watch them all closely</li>
<li>they are not allowed to leave the application until done.</li>
<li>they cannot send/receive phone calls or messages during the task.</li>
<li>the monitor receives notification of various steps during the task</li>
<li>the monitor is notified when the task is completed, or the app is exited</li>
<li>the app sends a heartbeat, so the monitor also knows if signal is lost</li>
<li>Jailbreak is not an option.</li>
<li>The app should also work on iPod Touch.</li>
</ul>

<p>So the things I need to do that seem dicey to me are</p>

<ul>
<li>can I turn off (or require the user to turn off) phone and sms but still be able send http to my server</li>
<li>can I prevent an app from being switched out (even if, say an alarm app triggers or the phone rings).</li>
<li>failing prevention, can I at least detect any of these events and notify my server.</li>
<li>failing notification, can I record the event for the monitor to check later.</li>
</ul>

<p>The user will be aware (and in fact welcome) these restrictions. It's a trust issue - the user must not seek help or use a helper app to solve the puzzle, and wants the monitor (and other contestants) to <strong>know</strong> that he did not. It's feasible for the user to click on an "OK, I understand and approve" screen at the beginning, but not for each communication to the server.  </p>

<p>The app would only communicate with a central server (run by my company) - the monitor would not be able to buy the server software, and the url's of the server would not be user (or monitor) modifiable.</p>

<p><em>Hey! This looks like an app for taking exams.  Not what I am doing, but that would be cool too!</em></p>

<p>EDIT --</p>

<p>I changed the title and am adding a few more parts to the question, based in part on mmc's answer. The App may run in an offline mode that would have to do the following:</p>

<p>So using the exam analogy, the user off line experience would be something like this</p>

<ol>
<li>Launch App</li>
<li>App download test questions, registers start time, etc.</li>
<li>Turn off phone (if app can't do it by itself)</li>
<li>Disable any app that might interrupt my App (can app do this?)</li>
<li>Resume and Take Test</li>
<li>Indicate test done (or finish last problem).</li>
<li>Turn on phone (if app can't) and restart App (if needed).</li>
<li>App uploads test results and log of any interruptions.</li>
</ol>

<p>So the question becomes</p>

<ul>
<li>Am I sure that I at least get to log any interruption I can't prevent</li>
<li>can I know the cause of the interruption (phone answered, alarm launch, user initiated)?</li>
<li>can the user be prevented from modifying the log</li>
<li>can I know what other Apps are running when I start? (to guard against a daemon that occasionally displays a hint or something.</li>
</ul>

<p>I would still like to run with real time uploads, so a few other ideas come to mind. </p>

<ul>
<li>If I can reliably detect and record that the phone or another app was used, that might be almost as good as preventing it.</li>
<li>Can the user prevent the phone from ringing even if it's on (eg. call forward + ringer off)</li>
<li>Can my app know if the ringer is off</li>
<li>Same question for sms messaging</li>
<li>If I can't block it, can the user just ignore (silent) call or message and not leave my App. Would my app know that? </li>
</ul>
