是否可以使用 NSTimer 和 UIDatepicker 来发出警报?
我有一个可以播放一些环境噪音的应用程序。我为它安装了一个睡眠计时器和一个本地通知程序,它们工作正常,但通知程序仅在应用程序位于后台时才会触发。
我希望能够安装一个用户可以使用日期选择器设置的标准闹钟,即用户在日期选择器上选择上午 07:15,这会触发此时播放的声音。这可以做到吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会坚持使用本地通知,您可以在应用程序处于活动状态时使用
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
监听它们并播放声音,您可以设置通知的
soundName
属性。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.