Anton Platonov
Anton Platonov

Reputation: 389

How to make a timer app that could run even when the app is in the background mode

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?

Upvotes: 0

Views: 94

Answers (2)

Simo
Simo

Reputation: 2202

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

Upvotes: 0

rckoenes
rckoenes

Reputation: 69499

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.

External accessory communication option ins capabilities

Upvotes: 1

Related Questions