关闭一系列 UILocalNotifications 或实现相同功能的替代方法
我正在构建一个小应用程序,我可以用它来进行间歇训练,
它安排了一系列UILocalNotifications
,所有安排都在同一时间
时间和所有的发射都在几分钟之内。
这个想法是你戴上耳机并开始锻炼,
当你听到一种声音时你会休息,而当你听到另一种声音时
听起来你锻炼了。我使用本地通知执行此操作,它有效
很好。这样做的原因不仅仅是
我想要让应用程序与计时器一起运行
Nike +iPod 应用程序同时在前台运行。
通知只是一个警报和一个“确定”按钮:
[notif setHasAction:NO];
所以想法是:戴上耳机,启动我的应用程序,它会安排一系列通知 - 然后开始 Nike +iPod 锻炼。当您听到通知声音时,从休息更改为锻炼,反之亦然。
好的,当锻炼结束时,屏幕上会显示 15 条以上的通知,需要手动关闭它们,这有点烦人,而且对用户来说一点也不友好。
我现在的问题是是否有办法只发布声音通知? 实现应用程序在后台时获取“声音指示器”的功能?
或者确保在弹出新通知时删除较早的通知,或者是否有不同/更好的方法来 一点经验或替代方案的好主意:) 提前致谢。
I am building a small app that I can use to do Interval Training,
it schedules a series of UILocalNotifications
, all scheduled at the same
time and all fired within a few minutes of each other.
The idea is that you put in your headphones and start a workout,
when you hear one kind of sound you rest and another kind of
sound you workout. I do this with localnotifications, it works
just fine. The reason for doing it like this and not just
having the app run with a timer is that I would like for
the Nike +iPod app to run in the foreground at the same time.
The notifications are just an alert and an OK button:
[notif setHasAction:NO];
So the idea is: Pop in the headphones, start my app, it schedules a series of notification - then start the Nike +iPod workout. When you hear the Notification sound, change from rest to workout or vice versa.
Ok, when the workout is over there are 15+ notifications on the screen and they need to be manually dismissed, this is a bit annoying and not at all user friendly.
My question is now if there is a way to post only sound notifications? OR make sure earlier notifications are removed as new ones pop up OR is there a different/better way of going about achieving the functionality of getting a "sound indicator" while the app is in the background?
Hope someone can lend a bit of experience or a good idea for an alternative:)
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法确认这实际上效果如何,但如果您在创建 UILocalNotification 对象时将 alertBody 属性设置为 nil (这是默认值),它应该会阻止警报当你开火时出现在屏幕上。
此外,您可能还需要将 hasAction 属性设置为 NO,这会阻止用户看到操作按钮(如果有警报)或滑块(如果设备已锁定) 。
但至于实际堆叠的通知警报 - 我不相信有任何方法可以阻止它们堆叠。这可能值得提高 Radar 的水平,因此苹果可以考虑在未来的 iOS 版本中允许这种情况发生。
I can't confirm how well this would actually work, but if you set the alertBody property on your UILocalNotification object to nil (this is the default value) when you create them, it should prevent an alert from appearing on screen as you fire them.
In addition, you might also want to set the hasAction property to NO, which prevents the user from seeing the action buttons (if you had an alert), or the slider (if they had the device locked).
But as for the actual stacked notification alerts - I don't believe there's any way to prevent them getting stacked. That's something which might be worth raising a Radar for, so Apple could consider allowing that to happen in future iOS versions.