[英]Redirect to view on taping push message from notification bar in IOS
我正在尝试在ios中编写聊天应用程序。 如果应用程序在后台运行或被终止,我需要知道如何在通知栏上点击推送消息时重定向到任何垂直视图。
需要尽快回复!
所以...当应用程序未运行且收到推送通知时,当用户单击推送通知时,该应用程序将启动,现在...推送通知内容将在其-didFinishLaunchingWithOptions:方法中可用launchOptions参数。
换句话说... -didReceiveRemoteNotification这次将不执行,您还需要执行以下操作:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//...
NSDictionary *userInfo = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
if(apsInfo) {
//there is some pending push notification, so do something
//in your case, show the desired viewController in this if block
}
//...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.