diff --git a/example/App.js b/example/App.js index c2d5bd0b0..bb11b6920 100644 --- a/example/App.js +++ b/example/App.js @@ -108,6 +108,7 @@ export const App = () => { subtitle: 'subtitle', body: 'body', category: 'test', + threadId: 'thread-id', fireDate: new Date(new Date().valueOf() + 2000), repeats: true, }); @@ -220,6 +221,7 @@ export const App = () => { `Alert title: ${notification.getTitle()}, Alert subtitle: ${notification.getSubtitle()}, Alert message: ${notification.getMessage()}, + Thread Id: ${notification.getThreadID()}, Action Id: ${notification.getActionIdentifier()}, User Text: ${notification.getUserText()}, Notification is clicked: ${String(isClicked)}.`, diff --git a/index.d.ts b/index.d.ts index 3b3346c02..2797c14ff 100644 --- a/index.d.ts +++ b/index.d.ts @@ -159,6 +159,10 @@ export type NotificationRequest = { * The category of this notification. Required for actionable notifications. */ category?: string; + /** + * The thread identifier of this notification. + */ + threadId?: string; /** * The date which notification triggers. */ diff --git a/ios/RNCPushNotificationIOS.m b/ios/RNCPushNotificationIOS.m index 604ddf74b..3c63eaebc 100644 --- a/ios/RNCPushNotificationIOS.m +++ b/ios/RNCPushNotificationIOS.m @@ -95,6 +95,12 @@ + (UNNotificationRequest *)UNNotificationRequest:(id)json content.body =[RCTConvert NSString:details[@"body"]]; content.badge = [RCTConvert NSNumber:details[@"badge"]]; content.categoryIdentifier = [RCTConvert NSString:details[@"category"]]; + + NSString* threadIdentifier = [RCTConvert NSString:details[@"threadId"]]; + if (threadIdentifier){ + content.threadIdentifier = threadIdentifier; + } + content.userInfo = [RCTConvert NSDictionary:details[@"userInfo"]]; if (!isSilent) { content.sound = [RCTConvert NSString:details[@"sound"]] ? [UNNotificationSound soundNamed:[RCTConvert NSString:details[@"sound"]]] : [UNNotificationSound defaultSound]; diff --git a/js/index.js b/js/index.js index 3d1df703c..f18ef2d16 100644 --- a/js/index.js +++ b/js/index.js @@ -481,6 +481,7 @@ class PushNotificationIOS { this._alert = nativeNotif.body; this._title = nativeNotif?.title; this._subtitle = nativeNotif?.subtitle; + this._threadID = nativeNotif['thread-id']; this._data = nativeNotif.userInfo; this._category = nativeNotif.category; this._fireDate = nativeNotif.fireDate; diff --git a/js/types.js b/js/types.js index b632ada8a..aa828e820 100644 --- a/js/types.js +++ b/js/types.js @@ -28,6 +28,10 @@ export type NotificationRequest = { * The category of this notification. Required for actionable notifications. */ category?: string, + /** + * The thread identifier of this notification. + */ + threadId?: string, /** * The date which notification triggers. */