开发者

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

开发者 https://www.devze.com 2023-02-01 23:58 出处:网络
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 ap开发者_如何学运维p is in the backgro

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 ap开发者_如何学运维p 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消