File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
iOS_SDK/OneSignalSDK/Source Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -566,16 +566,33 @@ + (UNNotificationRequest*)prepareUNNotificationRequest:(OSNotification*)notifica
566566 return [UNNotificationRequest requestWithIdentifier: identifier content: content trigger: trigger];
567567}
568568
569+ + (UNNotificationAction *)createActionForButton : (NSDictionary *)button {
570+ if (@available (iOS 15.0 , *)) {
571+ UNNotificationActionIcon *icon;
572+ if (button[@" systemIcon" ]) {
573+ icon = [UNNotificationActionIcon iconWithSystemImageName: button[@" systemIcon" ]];
574+ } else if (button[@" templateIcon" ]) {
575+ icon = [UNNotificationActionIcon iconWithTemplateImageName: button[@" templateIcon" ]];
576+ }
577+ return [UNNotificationAction actionWithIdentifier: button[@" id" ]
578+ title: button[@" text" ]
579+ options: UNNotificationActionOptionForeground
580+ icon: icon];
581+ } else {
582+ return [UNNotificationAction actionWithIdentifier: button[@" id" ]
583+ title: button[@" text" ]
584+ options: UNNotificationActionOptionForeground ];
585+ }
586+ }
587+
569588+ (void )addActionButtons : (OSNotification*)notification
570589 toNotificationContent : (UNMutableNotificationContent *)content {
571590 if (!notification.actionButtons || notification.actionButtons .count == 0 )
572591 return ;
573592
574593 let actionArray = [NSMutableArray new ];
575594 for (NSDictionary * button in notification.actionButtons ) {
576- let action = [UNNotificationAction actionWithIdentifier: button[@" id" ]
577- title: button[@" text" ]
578- options: UNNotificationActionOptionForeground ];
595+ let action = [self createActionForButton: button];
579596 [actionArray addObject: action];
580597 }
581598
You can’t perform that action at this time.
0 commit comments