didFinishLaunchingWithOptions 应用程序关闭时的 APNS

didFinishLaunchingWithOptions APNS when app is close

我正在尝试在应用程序关闭时连接通知。我需要从 APNS 获取消息并通过 id 打开所需的文章。问题是消息没有被 APNS 在函数 didFinishLaunchingWithOptions 中读取。不知错在哪里。我正在尝试解析 (NSDictionary *) launchOptions 并提取文章的 id。在函数内部 - didReceiveRemoteNotification 一切正常。

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

[self settingMenuNotification];
[self restKitConfiguration];

[self registerSettingsAndCategories];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSLog(@"%@",[paths objectAtIndex:0]);

if(launchOptions != NULL) {
    NSDictionary *userInfo = [launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
    [self openNewsDetailNotification:apsInfo];
}

return YES;
}

-(void) openNewsDetailNotification:(NSDictionary*)apsInfo {
if( [apsInfo objectForKey:@"id"] != NULL) { //id - id_article
    NSString *id_article = [apsInfo objectForKey:@"id"];

    NSNumber  *objectId = [NSNumber numberWithInteger: [id_article integerValue]];
    NSLog(@"Получил id %@", id_article);

    // Загружаем статью
    UIWindow *window=[UIApplication sharedApplication].keyWindow;
    UIViewController *root = [window rootViewController];
    UIStoryboard *storyboard = root.storyboard;
    NewsDetailViewController *newsVC = (NewsDetailViewController*)[storyboard instantiateViewControllerWithIdentifier:@"NewsDetailViewController"];

    newsVC.objectId = objectId;

    UINavigationController *navController = (UINavigationController *)self.window.rootViewController;
    [navController.visibleViewController.navigationController pushViewController:newsVC animated:YES];
}
}

me.I 在 that.Use 这段代码中添加了延迟,而不是直接调用函数。

也发生了同样的情况。
            [self performSelector:@selector(openNewsDetailNotification:) withObject:apsInfo afterDelay:6.0f];