GenericPtr
GenericPtr

Reputation: 686

Playing a sound periodically in the background on iOS

I'd like to play a sound periodically while the app is in the background but after doing some research it's not certain if this is possible. Before I give up or waste too much time trying I want to double check with the community if this is really possible or not.

I figured out how to enable playing sounds while the app is in the background but the app is still eventually killed and the timer stops firing (there's a 10 minute period it runs in suspended mode if I use beginBackgroundTask: but that's not enough). Other ideas I had:

1) There appears to be a "background fetch" mode which could maybe be used like a timer but this is a hack and may be rejected by Apple.

2) Loop blank audio in the background or some other looping part of audio API's to keep the app alive? Again Apple may reject that even it's possible.

3) Enable the location API to keep the app alive and play audio. Hack again, bad for battery and Apple 99% will reject this.

4) I read somewhere that push notifications could work for this but that requires a complicated server backend and if it's possible that last resort.

Are any of those methods viable or are there others?

Upvotes: 0

Views: 380

Answers (1)

Rukshan
Rukshan

Reputation: 8066

You can use scheduled Local Notifications with sounds.

Upvotes: 1

Related Questions