Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actionable notification in iOS8 not opening the app

Actually i am working in actionable notification. Everything works well i am getting button trigger action but the problem is when i tap the button the app is not opening. When i manually open the app its triggering corresponding action and going to exact screen but its not happening when i tap the button.

This is setup of my actionable notification

NSString * const NotificationCategoryIdent  = @"ACTIONABLE";
NSString * const NotificationActionOneIdent = @"ACTION_ONE";
NSString * const NotificationActionTwoIdent = @"ACTION_TWO";

-(UIMutableUserNotificationCategory*)registerActions {

    UIMutableUserNotificationAction *action1;
    action1 = [[UIMutableUserNotificationAction alloc] init];
    [action1 setActivationMode:UIUserNotificationActivationModeBackground];
    [action1 setTitle:@"Open"];
    [action1 setIdentifier:NotificationActionOneIdent];
    [action1 setDestructive:NO];
    [action1 setAuthenticationRequired:NO];

    UIMutableUserNotificationAction *action2;
    action2 = [[UIMutableUserNotificationAction alloc] init];
    [action2 setActivationMode:UIUserNotificationActivationModeBackground];
    [action2 setTitle:@"Delete"];
    [action2 setIdentifier:NotificationActionTwoIdent];
    [action2 setDestructive:NO];
    [action2 setAuthenticationRequired:NO];

    UIMutableUserNotificationCategory *actionCategory;
    actionCategory = [[UIMutableUserNotificationCategory alloc] init];
    [actionCategory setIdentifier:NotificationCategoryIdent];
    [actionCategory setActions:@[action1, action2]
                    forContext:UIUserNotificationActionContextDefault];

    NSSet *categories = [NSSet setWithObject:actionCategory];
    UIUserNotificationType types = (UIUserNotificationTypeAlert|
                                    UIUserNotificationTypeSound|
                                    UIUserNotificationTypeBadge);

    UIUserNotificationSettings *settings;
    settings = [UIUserNotificationSettings settingsForTypes:types
                                                 categories:categories];


    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];

    return actionCategory;
 }

What could be exact problem? Can some one help me.. Thanks in advance.

like image 688
Yohan Avatar asked Mar 17 '23 23:03

Yohan


1 Answers

[action1 setActivationMode:UIUserNotificationActivationModeBackground];

Should be:

[action1 setActivationMode:UIUserNotificationActivationModeForeground];

This is what triggers the launch of your application following a button press.

like image 69
Wes Hager Avatar answered Apr 01 '23 14:04

Wes Hager