点击推送通知时不显示正确的视图控制器

时间:2012-05-02 01:24:03

标签: objective-c ios xcode

我已经实现了推送通知,并且在点击通知时尝试将用户带到另一个视图控制器(而不是只打开应用)。我离开苹果网站的例子,但还没有运气。

它似乎从未输入我应该的代码。我试着用NSLog来证明这一点,我是对的。

有谁知道为什么?我想实现的视图控制器叫做statsViewController。

由于

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

NSDictionary *remoteNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];

if (remoteNotif) {      


    NSLog (@"We are here now");
    [self handleRemoteNotification:application userInfo:remoteNotif]; //custom method where View controller will be implemented
    return YES;
}

[window addSubview:tabBarController.view];
[window makeKeyAndVisible];

return YES;
}


-(void) handleRemoteNotification:(UIApplication *)application userInfo:(NSDictionary *)userInfo {
application.applicationIconBadgeNumber = 0;

statsViewController* viewController = [[statsViewController alloc] init];
[navController pushViewController:viewController animated:YES]; //Don't think this is right since I never use it in didFinishLaunching... I simply just declared it delegate.h
[viewController release];

 }

0 个答案:

没有答案