I created a local notification in this mode:
AppDelegate.m at lunch time
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init];
acceptAction.identifier = @"ACCEPT_ACTION";
acceptAction.title = @"ACCEPT_TITLE";
acceptAction.activationMode = UIUserNotificationActivationModeForeground;
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)];
}
then I create a local notification:
+ (void)sendLocalNotification:(NotificaObject*)n
{
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.category = @"testCategory";
localNotif.alertBody = @"First Test mex, no action";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
localNotif.userInfo = [NSDictionary dictionaryWithObject:@"0" forKey:@"id"];
localNotif.fireDate = [NSDate dateWithTimeIntervalSinceNow:5];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
NSLog(@"Sending Local notification");
}
When FIRE is notified, if the application (iOS8) has a FOREGROUND value in AppDelegate, it is called
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
and NEVER call
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler
if the application (iOS8) is in the background, only didReceiveLocalNotification call
I can't understand why handleActionWithIdentifier never calls
I am using xcode6.01 and developing for ios7 / 8, what am I doing wrong?
source
share