通过UILocalNotification区分app是否启动

发布于 2024-11-19 01:31:30 字数 270 浏览 4 评论 0原文

我正在开发一个闹钟应用程序,最近几天我一直被困住。我希望你们能帮忙。

我的问题是;

有没有办法区分应用程序是通过UILocalNotificationalertAction打开的还是只是定期打开的?

我想使用 UILocalNotification 创建贪睡功能,因此,如果用户点击 LocalNotification 上的操作按钮打开应用程序,则会启动贪睡机制(但显然,如果用户定期启动,我不希望该机制启动)打开应用程序设置时间或其他内容)

非常感谢您的帮助!

I am working on a alarm clock app and I've been stuck for the last couple of days. I was hoping you guys could help out.

My question is;

Is there any way to distinguish whether the app was opened through the UILocalNotification alertAction or just opened regularly?

I want to use the UILocalNotification to create a snooze feature, so if the app is opened by the user tapping on the action button on the LocalNotification, a snooze mechanism will launch (but obviously i don't want that to launch if the user regularly opens the app to set the time or something)

Thank you so much for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

无人接听 2024-11-26 01:31:30

是的,这是可能的,如 UILocalNotifaction 类中所述参考


应用程序:didFinishLaunchingWithOptions:
应用程序委托可以的方法
获取UILocalNotification对象
来自传入的选项字典...

因此您可以检查选项字典以查看通知是否存在。如果是的话,这就是应用程序的启动方式。

Yes this is possible as described in the UILocalNotifaction class reference

In the
application:didFinishLaunchingWithOptions:
method the application delegate can
obtain the UILocalNotification object
from the passed-in options dictionary...

Therefore you can check the options dictionary to see if the notification is present. If it is then that's how the app was launched.

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