1

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

似乎它甚至从未按应有的方式进入我的代码。我尝试放置一个 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];

 }
4

0 回答 0