I am trying to create an alarm clock app which plays either downloaded or streamed video and audio as a local notification. For Android this is doable but for IOS I know that apple has restrictions.
I have noticed that Rise and The Rock Clock require you to keep the app in the foreground (example below) . I have read that they do this by disabling multitasking UIApplicationExitsOnSuspend
.
I am wondering whether this is still the only (best?) way to show custom notifications or whether they are just supporting older operating systems and there is changes in IOS that provide a better user experience?
Thanks
There are not so much possible ways to do this and no one is good.
URLSession with background configuration. According to documentation You can schedule request. Works only from iOS 11, no guarantee that request will be executed.
Use VoIP or silent push. This types of pushes have possibility to launch app in background when received by device. Tricky way but can do the job. Not helpful if user has no internet connection.
Keep app in foreground. Simplest way and works like a charm. Too heavy for device battery.
UPD: Just to gather all answers in one place (Thanks to @jba).
There is also possibility to use "Audio and Airplay" background category. You can play "silence" or record audio when device is locked. This is very energy consumnable way, also, some of OS interuptions, like phone call, can stop audio playback/record and app can be suspended.
Apple won't give you much ways to achieve this, but the few you have are well and quite precisely documented. For your app I would advise to go with the "Audio and Airplay" option as it will allow you to play and/or record audio in the background. Then your hard work is to find the right way to explain why you do this to your users, and what is the benefit for them... At the end this feature would let your app alive all the time until firing the alarm and then play your audio file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With