So now using All the information presented so far we can turn to our hypothetical Marathon Runner trainee. She has the Pulse monitor band wrapped around her wrist and the Jambra headset mic over her right earlobe. Using the headset she can switch between Music applications on her phone as well as call up spoken statistics from the HeartMonitor application. She can also Post her progress to her Facebook Wall using the HealthShare application.
The Heart Monitor accessory allows for a single serial radio connection.
When she requests the Heart Monitor application using a voice command, HealthMonitor starts if it's not running already and connects to the Accessory. The launcher enters background and then is suspended because it's not one of the apps "blessed" to run in the background. On receiving AccessoryDidConnect HealthMonitor issues an OpenUrl request for the Launcher. HealthMonitor moves to the background but because it is a "background allowed" application it stays connected to the accessory and can still alert the runner of changes in Pulse Rate via notification Alerts.
The User now issues the "Pandora" voice command to start Pandora Radio, once again the Launcher moves to the background and is suspended. HealthMonitor continues to receive updates from the Accessory.
Pandora now is in complete control, until the runner exits it. after which Pandora enters applicationDidEnterBackground and issues an openUrl back to the launcher. Now the Launcher is the foreground application, HealthMonitor continues to run in the background.
She can continue this round Robin cycle between opening applications, bringing to foreground or sending to backgrounds indefinitely. HealthMonitor will continue to receive updates until it becomes disconnected from the heart monitor or another forground app opens a EASession.
HealthMonitor talks to the heart monitor accessory using the ubiquitous NSStream that apple uses for virtually all stream connection. The same protocol can be used for tcp, bluetooth and IAP.
The runner now issues a voice command to start HealthShare, as before the launcher enters the background and shortly after a suspended state. HealthShare does open a session to the accessory. When HealthShare opens a stream to the heart Monitor HealthMonitor receives a NSStreamEndEncountered message , Since HealthMonitor no longer has an active session to the accessory it will eventually be suspended until such time it is brought again to the foreground. HealthShare issues an openURL request to the Launcher and enters the background. It is still receiving updates from the accessory.
Reality check : There doesn't seem to be any means to start an application in the background it must be "pushed" there by a foreground application, so apps must be specifically coded to return to the launcher with the openUrl method. Unfortunately there is no voice controled version of Pandora, the app mentioned here is simply a hypothetical version.
Comments