跳转到 application:didReceiveRemoteNotification 上的特定 UITableView:
当我的应用程序收到推送通知时, application:didReceiveRemoteNotification: 接收数据。当用户从通知打开应用程序时,我想跳转到堆栈中的最后一个 UITableView,以显示与推送通知相关的“详细信息”。
我能够跳转到 UITabBar 中的正确选项卡。
有没有办法从应用程序代理推送该选项卡中的视图,或者我是否以错误的方式处理此问题?
When my app receives a Push Notification, application:didReceiveRemoteNotification: receives the data. When the user open the app from a notification, I want to jump to the last UITableView in the stack, to display the 'details' related to the Push Notification.
I am able to jump to the correct tab in the UITabBar.
Is there a way to Push views in that Tab from the App Delegate, or am I going about this the wrong way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您已经能够跳转到正确的选项卡,那么您就快成功了。
一种方法是将推送警报信息保存到 nsuserdefault 中...可能以“didReceiveRemoteNotification”中的字典对象的形式保存。这就像保存 Web 开发中的 cookie 以供以后使用。
然后,对于您跳转到的选项卡中显示的视图控制器,您可以检查 viewWillAppear 并查看 nsuserdefault 中是否存储了任何内容,并在那里获取保存的通知数据,您可以在中查找相应的数据你的 UITableViewDataSource。
一旦你有了这个,你就可以调用或做你通常会做的事情,如果你选择了由表格单元格表示的相同数据/对象,并将所需的视图(控制器)推入视图。
一旦尝试推送视图,请确保删除保存在 NSUserDefault 中的对象。
If you're already able to jump to the correct tab, you're almost there.
One way to do it would be to save off the push alert information into nsuserdefault... maybe in a form of a dictionary object in the "didReceiveRemoteNotification". It's like of like save off a cookie web development for later use.
Then for the viewcontroller you're displaying in the tab that you jump to, you could do a check in viewWillAppear and see if you have anything stored in your nsuserdefault and grab the saved off notification data there and you can look up the corresponding data in your UITableViewDataSource.
Once you have that, you can call or do what ever you'd normally do had you selected the same data/object represented by a table cell and push the desired view (controller) into view.
Make sure to remove the object saved in NSUserDefault once you're attempted to push the view.