是否可以使用 NSTimer 和 UIDatepicker 来发出警报?

发布于 2024-10-10 06:51:25 字数 155 浏览 0 评论 0原文

我有一个可以播放一些环境噪音的应用程序。我为它安装了一个睡眠计时器和一个本地通知程序,它们工作正常,但通知程序仅在应用程序位于后台时才会触发。

我希望能够安装一个用户可以使用日期选择器设置的标准闹钟,即用户在日期选择器上选择上午 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零崎曲识 2024-10-17 06:51:25

我会坚持使用本地通知,您可以在应用程序处于活动状态时使用

- (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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文