UILocalNotification iOS8 handleActionWithIdentifier nunca ha llamado

He creado una notificación local en este modo:

AppDelegate.m en el almuerzo

if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { // Setup each action thar will appear in the notification UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init]; acceptAction.identifier = @"ACCEPT_ACTION"; // Identifier is returned in handleActionWithIdentifier: after the user taps on an action acceptAction.title = @"ACCEPT_TITLE"; acceptAction.activationMode = UIUserNotificationActivationModeForeground; //Brings the app into the foreground when action tapped UIMutableUserNotificationCategory *not_cat = [[UIMutableUserNotificationCategory alloc] init]; not_cat.identifier = @"testCategory"; [not_cat setActions:@[acceptAction] forContext:UIUserNotificationActionContextDefault]; NSSet *categories = [NSSet setWithObjects:not_cat, nil]; UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:categories]; [[UIApplication shanetworkingApplication] registerUserNotificationSettings:notificationSettings]; [[UIApplication shanetworkingApplication] registerForRemoteNotifications]; } else { [[UIApplication shanetworkingApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; } 

entonces creo una notificación local:

 + (void)sendLocalNotification:(NotificaObject*)n { UILocalNotification *localNotif = [[UILocalNotification alloc] init]; // Set the category to the category that contains our action localNotif.category = @"testCategory"; localNotif.alertBody = @"First Test mex, no action";//n.titolo; localNotif.soundName = UILocalNotificationDefaultSoundName; localNotif.applicationIconBadgeNumber = 1; localNotif.userInfo = [NSDictionary dictionaryWithObject:@"0" forKey:@"id"]; localNotif.fireDate = [NSDate dateWithTimeIntervalSinceNow:5]; //5 seconds [[UIApplication shanetworkingApplication] scheduleLocalNotification:localNotif]; NSLog(@"Sending Local notification"); } 

Cuando se llama INCREÍBLE a la notificación si la aplicación (iOS8) es PRÓXIMA en AppDelegate se llama

  - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification 

y NUNCA llamar

 - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler 

si la aplicación (iOS8) está en el background, solo se llama didReceiveLocalNotification

No puedo entender por qué handleActionWithIdentifier NUNCA llamo

Utilizo xcode6.01 y desarrollo para ios7 / 8, ¿qué estoy haciendo mal?

Tipo. Parece que se está registrando para la Notificación remota y para que el controller se aplique a la Notificación local. Por favor regístrese para la Notificación Local para que funcionen los oyentes.

¿Adjunta cualquier dispatch_get_main_queue?

Hago un bucle en la queue principal y la aplicación: handleActionWithIdentifier: forLocalNotification: completionHandler: el método nunca se llama

 dispatch_async(dispatch_get_main_queue(), ^{ while (YES) { [NSThread sleepForTimeInterval:1.0]; } }); 

La solución está utilizando dispatch_get_global_queue

 dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ while (YES) { [NSThread sleepForTimeInterval:1.0]; } }); 

Solo tres pasos para las notifications locales:

1.- en la AppDelegate, didFinishLaunchingWithOptions le dice que la aplicación está trabajando con notifications:

 if(UIApplication.instancesRespondToSelector(Selector("registerUserNotificationSettings:"))) { application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: .Sound | .Alert | .Badge, categories: nil)) } 

2.- Escribir un controller para las notifications (lo que sucederá cuando ocurra la notificación local):

 func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forLocalNotification notification: UILocalNotification, completionHandler: () -> Void) { println("notification is here. Open alert window or whatever") // Must be called when finished completionHandler() } 

3.- En su aplicación, configura la notificación local de esta manera:

  var localNotification: UILocalNotification = UILocalNotification() localNotification.alertAction = "Your Alarm!" localNotification.alertBody = "Your description" localNotification.fireDate = NSDate(timeIntervalSinceNow: 10) // your time localNotification.soundName = UILocalNotificationDefaultSoundName // there are more and different options UIApplication.shanetworkingApplication().scheduleLocalNotification(localNotification) 

Para mí está funcionando con ios 8.3 y swift 1.2