应用关闭后如何处理推送有效负载?

我正在使用以下内容向我的用户发送推送有效负载:

{"aps": {"alert": "Go To Google", "sound": "Default","url":"http://www.google.com"}} 

当pp运行但在后台时,一切顺利。 如果我收到推送并且应用程序已关闭,我打开它并且没有任何反应。 我试图重定向到有效载荷中的这个URL。 当应用程序从后台运行时它再次运行良好。

这是到目前为止AppDelegate.m的实现:

 -(void)Redirect:(NSString*)url{ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; NSLog(@"%@",url); } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { RedirectedUri = [[userInfo objectForKey:@"aps"] objectForKey:@"url"]; NSLog(@"%@",RedirectedUri); [self Redirect:RedirectedUri]; } 

需要一些帮助。

另外,在代码中添加以下内容:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self applicationDidFinishLaunching:application]; if (launchOptions != nil) { NSDictionary* dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (dictionary != nil) { RedirectedUri = [[dictionary objectForKey:@"aps"] objectForKey:@"url"]; [self Redirect:RedirectedUri]; } } return YES; }