从appDelegate中的didReceiveRemoteNotification执行segue

时间:2013-07-23 17:56:51

标签: ios objective-c push-notification appdelegate

编辑:在进一步说明之前,我应该说我已经找到了解决方案,如果我正在尝试使用基于导航控制器的应用程序,但这不是我的情况。

我创建推送通知以获得Job,我已记录所有内容并收到推送,单击推送通知并收到正确的日志。

我的目标是,我想执行一个segue来访问我的特定视图控制器,具体取决于所要的工作。

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    NSString *job = [[userInfo valueForKey:@"aps"] valueForKey:@"job"];

    if([job isEqualToString: @"msg"]) {
        NSLog(@"Going to message");
    }
    if ([job isEqualToString: @"friend"]) {
        NSLog(@"Going to friend request");
    }
    if ([job isEqualToString: @"inv"]) {
        NSLog(@"Going to invite notifications");
    }
    if ([job isEqualToString: @"find"]) {
        NSLog(@"Going to find notifications");
    }
}

1 个答案:

答案 0 :(得分:1)

  if([job isEqualToString: @"msg"]) {
    NSLog(@"Going to message");
    UIStoryboard* storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    UIViewController* detailVC = [storyBoard instantiateViewControllerWithIdentifier:@"msg"];
    [self.window.rootViewController presentViewController:detailVC animated:YES completion:nil];
 }