Question

I am currently building a music app which takes controls from the iOS7 control center. One of the features I noticed is that if I press the "play" control button, my app will start, even if it has been killed. This is not something which I want to happen, so I added return NO in didFinishLaunchingWithOptions if the app is launching in the background to prevent the initialization process.

Unfortunately, this does not change the fact that the app has still started, and didFinishLaunchingWithOptions is not called again (and nothing is initialized). Since I cannot have the app forcefully kill itself when I don't want it to start, is there any way to prevent the app from launching? I had thought that returning NO would have done the trick, but this does not appear to be the case.

Was it helpful?

Solution

I have found one of the main causes to this issue. It had to do with the audio session and the various notifications/delegates which the app was registered for. In the AppDelegate's applicationWillTerminate: I had to make sure to call:

[[UIApplication sharedApplication] endReceivingRemoteControlEvents];

[[AVAudioSession sharedInstance] setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&audioSessionError];

And also unregister for any audio notifications (interrupts and route changes).

OTHER TIPS

Do you want your app to run in the background at all?

If not, you can simply add a info.plist value so it doesn't enter background and just closes when a user hits the home button.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top