Skip to content

Commit

Permalink
feat(ios): add threadIdentifier and summaryArgument to LocalNotificat…
Browse files Browse the repository at this point in the history
…ion (#2396)

* add localnotification threadIdentifier and summaryArgument properties for iOS

* change new options text

Co-authored-by: Patrick Gingras <775.pg.12@gmail.com>
  • Loading branch information
jcesarmobile and p7g authored Jan 31, 2020
1 parent 1f7e40d commit 7c5f30b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/src/core-plugin-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,14 @@ export interface LocalNotification {
attachments?: LocalNotificationAttachment[];
actionTypeId?: string;
extra?: any;
/**
* iOS only: set the thread identifier for notification grouping
*/
threadIdentifier?: string;
/**
* iOS 12+ only: set the summary argument for notification grouping
*/
summaryArgument?: string;
}

export interface LocalNotificationSchedule {
Expand Down
10 changes: 10 additions & 0 deletions ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ public class CAPLocalNotificationsPlugin : CAPPlugin {
let sound = notification["sound"] as? String
let attachments = notification["attachments"] as? JSArray
let extra = notification["extra"] as? JSObject ?? [:]
let threadIdentifier = notification["threadIdentifier"] as? String
let summaryArgument = notification["summaryArgument"] as? String

let content = UNMutableNotificationContent()
content.title = NSString.localizedUserNotificationString(forKey: title, arguments: nil)
Expand All @@ -175,6 +177,14 @@ public class CAPLocalNotificationsPlugin : CAPPlugin {
if actionTypeId != nil {
content.categoryIdentifier = actionTypeId!
}

if let threadIdentifier = threadIdentifier {
content.threadIdentifier = threadIdentifier
}

if let summaryArgument = summaryArgument, #available(iOS 12, *) {
content.summaryArgument = summaryArgument
}

if sound != nil {
content.sound = UNNotificationSound(named: UNNotificationSoundName(sound!))
Expand Down

0 comments on commit 7c5f30b

Please sign in to comment.