从未调用UILocalNotification iOS8 handleActionWithIdentifier

ika*_*imo 5 xcode objective-c ios uilocalnotification ios8

我在这种模式下创建了一个本地通知:

AppDelegate.m在午餐时间

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 sharedApplication] registerUserNotificationSettings:notificationSettings];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
    } else {
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
    }
Run Code Online (Sandbox Code Playgroud)

然后我创建一个本地通知:

+ (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 sharedApplication] scheduleLocalNotification:localNotif];
    NSLog(@"Sending Local notification");
}
Run Code Online (Sandbox Code Playgroud)

如果应用程序(iOS8)在AppDelegate中为FOREGROUND,则通知FIRE时会被调用

 - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
Run Code Online (Sandbox Code Playgroud)

永远不要打电话

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler
Run Code Online (Sandbox Code Playgroud)

如果应用程序(iOS8)在后台只调用didReceiveLocalNotification

我无法弄清楚为什么handleActionWithIdentifier永远不会调用

我使用xcode6.01并为ios7/8开发,我做错了什么?