Reputation: 823
I know that you can for example play music in you app and it would be running in background but it looks like it's not working. I've this code when my application starts on iPhone:
pathToAudio = [[NSBundle mainBundle] pathForResource:@"silence" ofType:@"mp3"];
audioURL = [NSURL fileURLWithPath:pathToAudio];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioURL error:NULL];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:NULL];
audioPlayer.numberOfLoops = -1;
[audioPlayer play];
Result is that it plays music when I send app to background but other activities doesnt run. For example in my app I'm listening to socket and although music plays in background my app doesnt respond to incomming messages (it normally responds when app is in foreground). What do I do wrong? I've read that you can do other activities when playing music when app is in background but it looks like it doesn't work...
Edit: I have jailbroken iPhone so any unconventional methods are welcome. I know that Apple would reject my app if I was playing silent audio in background and I dont care about it. I just want to know how to make app running in background when playing music or in any other way... Maybe I need to have iPhone 4? I have iPhone 3G.
Upvotes: 1
Views: 973
Reputation: 171
You'll need to provide a specification for the info.plist file like the UIBackgroundModes.
Upvotes: 0
Reputation: 32681
Nothing, it's only possible to run audio in background (aside with some special cases like geoloc notifs & VoIP), not other stuff.
Upvotes: 3