当用户收到一个推送通知打开特定的选项卡/视图 [英] Open a specific tab/view when user receives a push notification

查看:104
本文介绍了当用户收到一个推送通知打开特定的选项卡/视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做类似Twitter的应用程序:当有人写我,我收到推送通知;如果我的通知幻灯片的应用程序启动,但不是在正常的数据流,它开始与鸣叫特定的观点,有人写信给我!

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!

在我的应用我有一些像一个RSS阅读器,当有新的消息推送通知到达。
所以,我想开了单一新闻观,而不是主视图(现在发生的事情)。

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).

我该怎么办?

感谢

推荐答案

您可以做两件事情。

一是检查 UIApplicationDelegate 方法的 launchOptions 字典

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

,以查看是否该应用是通过在通知用户点击发起。如果是这样,那么这个方法你可以把相应的视图控制器压入堆栈,就像你通常与应用程序内的使用。

to 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.

如果应用程序已经打开,但在后台,然后同样的理论适用,而是使用 UIApplicationDelegate

If the app is already open, but in the background then the same theory applies but instead use the UIApplicationDelegate method

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

请参阅this链接有关处理传入的通知。

See this link for information on handling incoming notifications.

这篇关于当用户收到一个推送通知打开特定的选项卡/视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆