Start looped audio from background?

I'm trying to do something similar to Tile.app. When it shows a notification, it plays a sound. That seems simple enough-- use

UILocalNotification
and include the sound file name. But local notifications limit sounds to no more than 30 seconds, and Tile's sound keeps playing for a whole lot longer than that. I expect it's looping, and it continues until I can't stand the noise any more.


The sound also plays even if the phone's mute switch is on, which doesn't happen with local notifications.


I thought maybe I could post a text-only local notification and have my app play the sound. But using

AVAudioPlayer
, the
play
method returns
NO
and the sound doesn't play.


I've seen it suggested that this is by design, that apps aren't supposed to be able to play sounds from the background-- only continue sound that's already playing. I'd accept that reasoning except that Tile does it, so it's obviously possible. One suggested workaround is to loop silent audio in the foreground and switch to non-silent audio when needed. Aside from being ugly, I'm pretty sure that violates Apple's app guidelines.


Some details that may be relevant:

  • I have the
    audio
    background mode in Info.plist
  • I use
    AVAudioSessionCategoryPlayback
    on the audio session, and the session should be active (at least,
    setActive:error:
    claims to succeed).


Any clues on how I could do this? I'm not tied to AVAudioPlayer, I'll use whatever might work.

Start looped audio from background?
 
 
Q