I have a simple timer app and I need it to work and send sound signals when using other system apps like iBooks. But when I press the Home button and the app goes in the background mode it seems to pause. The timer and sounds resume when I bring the View Controller back. What is the correct way to solve this?
Asked
Active
Viewed 87 times
0
-
App can't run in the background unless they are either VOIP, AudioStreamer, LocationBased or accessory apps. The use of timers is not possible in the background. You best option it to schedule a location notification and not use times. If your app is running you can handle the local notification. If you app is running in the background the user will be pressented with the notification. – rckoenes Dec 16 '16 at 09:55
-
I misused the term. I need it to run and send signals when using other apps like iBooks. – Anton Platonov Dec 16 '16 at 10:00
-
First you will not be able to detect if any other app is started since this is a breach of privacy. Apple will not allow it if you are going to deploy your app via the AppStore. – rckoenes Dec 16 '16 at 10:01
-
I think you misunderstood what I meant. Many apps are made like this. You can be running using a running app and listening to iTunes music or reading from iBooks if you read and run. – Anton Platonov Dec 16 '16 at 10:08
-
1You mean you want your app to run in the background, this is possible if your app is either a VOIP client, audio player, location based or accessory app. – rckoenes Dec 16 '16 at 10:10
-
Thanks for the answers. Which is a standard running app? – Anton Platonov Dec 16 '16 at 10:16
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/130774/discussion-between-anton-platonov-and-rckoenes). – Anton Platonov Dec 16 '16 at 10:20
2 Answers
1
If your app is an accessory app you need to add the background mode accessory.
You can do this from the capabilities tab in your target. If you do use this option and Apple finds that you are not commincateing with a external accessory your app will be rejected.

rckoenes
- 69,092
- 8
- 134
- 166
0
I would recommend looking at UILocalNotification (UNNotificationRequest if your targeting iOS 10 only).
When your app is running, you simply register a UILocalNotification to fire at a set date and time. This will then still fire when your app is in the foreground, backgrounded or removed from multitasking entirely.
Check out the documentation here:
https://developer.apple.com/reference/uikit/uilocalnotification

Simo
- 2,172
- 3
- 19
- 23