didReceiveRemoteNotification 和模态视图
我的应用程序委托有一个 RootViewController *viewController;并且应用程序会以该视图启动。
从现在开始,当用户导航到应用程序内的不同功能时,我将继续呈现模态视图(最多 3 级)。
我已将应用程序设置为接收推送通知,并且在应用程序委托内设置了 didReceiveRemoteNotification 来检索有效负载。
现在的问题是:
- 当收到推送通知时,我如何知道用户当前处于哪个模式视图?
- 如何关闭所有模态视图以返回到 RootViewController?我真的可以在应用程序委托中执行此操作吗?
My app delegate has a RootViewController *viewController; and the app launches with this view.
From here on I will continue to present modal views (up to 3 levels) as the user navigates to different functions within the app.
I have setup the app to receive push notifications, and I have didReceiveRemoteNotification inside the app delegate to retrieve the payload.
Now the questions:
- When the push notification is received, how can I know which modal view the user is currently in?
- How do I close all the modal views to return to the RootViewController? Can I actually do this within the app delegate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有通用的内置方法可以做到这一点。最好的解决方案可能是向您的应用程序委托添加一个属性,您可以在其中存储它。
当您呈现模态视图控制器时,请执行以下操作:
您还需要确保在关闭时丢失引用:
然后在您的应用程序委托中,您拥有关闭当前模态视图控制器并检查是否有模态所需的一切查看当前存在的控制器。
There's no generic built-in way of doing this. The best solution is probably to add a property to your app delegate where you can store it.
When you present modal view controllers, do this:
You also need to make sure you lose the reference when dismissing:
Then in your app delegate, you have everything you need in order to dismiss the current modal view controller and check if there is a modal view controller present at the moment.