0

Here is what I added in my iOS app:

- (void) schedule:(CDVInvokedUrlCommand*)command
{
    NSArray* notifications = command.arguments;

    [self.commandDelegate runInBackground:^{
        for (NSDictionary* options in notifications) {
            APPNotificationContent* notification;

            notification = [[APPNotificationContent alloc]
                            initWithOptions:options];
            notification.title = @"This is title2";
            notification.subtitle = @"This is subtitle";
            notification.body = @"This is body";
            notification.categoryIdentifier = @"demoCategory";
            NSLog(@"categoryIdentifier: %@", notification.categoryIdentifier);
            NSString* found;
            found = [_center hasActionGroup:notification.categoryIdentifier] ? @"yes" : @"no";
            NSLog(@"category existance: %@", found);

            [self scheduleNotification:notification];
        }

        [self check:command];
    }];
}

And here is what I received when it was triggered:

2022-12-09 13:11:12.595804+1300 MyApp[71182:11636137] NotificationCenter Handle push from foreground
2022-12-09 13:11:12.595994+1300 MyApp[71182:11636137] Notification received
2022-12-09 13:11:12.596147+1300 MyApp[71182:11636137] Push Plugin key: alert
2022-12-09 13:11:12.626052+1300 MyApp[71182:11637337] categoryIdentifier: demoCategory
2022-12-09 13:11:12.627402+1300 MyApp[71182:11637337] category existance: yes

I added two buttons in that category, but I ended up receiving a notification without any action button.

Is the categoryIdentifier not working? Or should I somehow check if the category is applied correctly?

Terry Windwalker
  • 1,343
  • 2
  • 16
  • 36
  • What is `APPNotificationContent`? Have you registered the notification categories as described here: https://developer.apple.com/documentation/usernotifications/declaring_your_actionable_notification_types?language=objc – HangarRash Dec 09 '22 at 02:02
  • @HangarRash It is actually "UNMutableNotificationContent", just renamed for some purpose. The categories are registered. – Terry Windwalker Dec 09 '22 at 02:51

0 Answers0