通过UILocalNotification区分app是否启动
我正在开发一个闹钟应用程序,最近几天我一直被困住。我希望你们能帮忙。
我的问题是;
有没有办法区分应用程序是通过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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是可能的,如 UILocalNotifaction 类中所述参考
因此您可以检查选项字典以查看通知是否存在。如果是的话,这就是应用程序的启动方式。
Yes this is possible as described in the UILocalNotifaction class reference
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.