redned
redned

Reputation: 301

Is it possible to make an alarm using NSTimer and UIDatepicker?

I have an app which plays some ambient noises. I have fitted it with a sleep timer and a local notifier which work fine, but the notifier will only fire when the app is in the background.

I would like to be able to fit a standard alarm clock that the user can set using the date picker, ie, the user picks 07:15 am on the date picker and this triggers a sound being played at this time. Can this be done?

Upvotes: 0

Views: 603

Answers (1)

James P
James P

Reputation: 4836

I would stick with local notifications, you can listen for them while the app is active using

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

And to play your sound you can set the soundName property of your notification.

Upvotes: 1

Related Questions