Ich erhalte eine Remote-Benachrichtigung und ändere entsprechend der Art der Benachrichtigung die View-Controller des Navigationscontrollers.Absturz beim Umgang mit Remote-Benachrichtigungen, wenn App nicht ausgeführt wird
Alles funktioniert gut, wenn die App im Vordergrund ist oder wenn die App im Hintergrund, aber nicht vollständig geschlossen ist (von der Multitasking-Leiste aus).
Aber wenn die App geschlossen ist und eine Remote-Benachrichtigung erhält, stürzt sie ab, sobald sie geöffnet wird. Mache ich einen Fehler bei der Einrichtung der ViewControllers?
Hier ist ein Code.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions {
// Push required screens into navigation controller
UILocalNotification *remoteNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
//Accept push notification when app is not open
if (remoteNotif) {
[self handleRemoteNotification:application userInfo:remoteNotif.userInfo];
return YES;
}
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
}
-(void) handleRemoteNotification:(UIApplication *)application userInfo:(NSDictionary *)userInfo {
application.applicationIconBadgeNumber = 0;
NSMutableArray *viewControllers = [NSMutableArray array];
[viewControllers addObject:driverWaitViewController];
[viewControllers addObject:newJobsViewController];
[navigationController setViewControllers:viewControllers];
}
Danke für Ihre Antwort Vakio. Das Problem ist etwas anderes. Bitte schau, wie ich es gelöst habe. – Prasanna
Ja, ich dachte, das wäre komisch, aber ich habe es nicht verstanden. Es tut uns leid. – vakio