RubenVot
RubenVot

Reputation: 186

How is possible to play an alarm in iOS if the application is closed?

I downloaded some Alarm Clock apps from the App Store and found they are able to keep playing a sound and even vibrating the phone for more than 30 seconds (Limitations from UILocalNotifications) I even forced to close the application and it still work!

I wonder how is this possible? Is there another method than UILocalNotification ? Are they using several notifications?

Thanks!

Upvotes: 6

Views: 2397

Answers (3)

dgund
dgund

Reputation: 3467

They could be using Push Notifications, but that would require an external server, internet, and is unlikely.

What is more likely is that they are just using UILocalNotifications. When you schedule one to go off at a specific time, it will go off at that time even if the app has been quit. The OS will direct all Local Notifications once they have been scheduled. Here's the Apple documentation on UILocalNotification.

EDIT: In response to your comment, scheduling one Local Notification, followed by scheduling a second one for 30 seconds later, and so on, is plausible. And to me, it seems like the only way if there is a 30 second restriction.

Upvotes: 4

hotpaw2
hotpaw2

Reputation: 70673

They could be background-capable audio apps (using UIBackgroundModes in the app's plist) and playing silence, using Audio Queues or the RemoteIO Audio Unit, even in the background, until time to mix in some alarm sounds or music.

Upvotes: 1

LJ Wilson
LJ Wilson

Reputation: 14427

I believe that if you schedule a UILocalNotification, the OS takes control of the notification and will execute it even when the application that scheduled it closes.

Upvotes: 6

Related Questions