我知道这是一个有点奇怪,但我已经写了这个代码,当用户点击一个推送通知,会启动特定的视图控制器。当我在设备上运行代码时,代码完美运行,但第二次从Xcode中拔出设备并再次运行,代码不会执行,并且当我单击推送通知时,视图控制器无法打开。代码不能执行的Xcode
下面是代码我有,如果需要更多信息,请这么说,我Appdelegate.m
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
if(apsInfo) {
//there is some pending push notification, so do something
//in your case, show the desired viewController in this if block
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert"
message:[NSString stringWithFormat:@"%@ ",[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]]
delegate:self cancelButtonTitle:@"Done"
otherButtonTitles:nil];
[alertView show];
UIViewController *vc = self.window.rootViewController;
NotificationViewController *pvc = [vc.storyboard instantiateViewControllerWithIdentifier:@"Alerts"];
[vc presentViewController:pvc animated:YES completion:nil];
}
}
打开我的视图控制器。
在此先感谢, 干杯
好了,事实证明,它的作品,如果应用程序仍然在后台还活着,但是当我从背景中删除应用程序,然后在视图控制器不启动。了... – Rayyan