我知道這是一個有點奇怪,但我已經寫了這個代碼,當用戶點擊一個推送通知,會啓動特定的視圖控制器。當我在設備上運行代碼時,代碼完美運行,但第二次從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