当用户收到推送通知时打开特定选项卡/视图
我想做一些像 Twitter 应用程序一样的东西:当有人给我写信时,我会收到推送通知;如果我“在通知上滑动”,应用程序将启动,但不是在正常流中,而是在特定视图中启动,其中包含有人给我写的推文!
在我的应用程序中,我有一个类似 RSS 阅读器的东西,当有新消息时,推送通知就会到达。 所以,我想打开“单一新闻视图”,而不是主视图(现在正在发生)。
我能做些什么?
谢谢
I want to do something like Twitter app: when someone write me I receive the push notification; if I "slide on the notification" the app starts, but not in the normal stream, it starts in a specific view with the tweet that someone wrote me!
In my app I have something like an RSS reader, and the push notification arrives when there is a new news.
So, I want to open the "single news view", and not the main view (that's happening now).
What can I do?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以做两件事。
一种方法是检查
UIApplicationDelegate
方法的launchOptions
字典,以查看应用程序是否是通过用户单击通知启动的。如果是这样,那么在该方法中,您可以将适当的视图控制器推送到堆栈上,就像通常在应用程序内使用一样。
如果应用程序已打开,但在后台,则适用相同的理论,但使用
UIApplicationDelegate
方法请参阅此链接了解有关处理传入通知的信息。
You can do two things.
One is to check the
launchOptions
dictionary of theUIApplicationDelegate
methodto see if the app was launched via a user clicking on a notification. If so, then in that method you can push the appropriate view controller onto the stack, just as you would normally with in-app usage.
If the app is already open, but in the background then the same theory applies but instead use the
UIApplicationDelegate
methodSee this link for information on handling incoming notifications.