Skip to content

Commit a5f9dae

Browse files
authored
feat: add threadIdentifier for local notification (#211)
1 parent c11b95e commit a5f9dae

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

example/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export const App = () => {
108108
subtitle: 'subtitle',
109109
body: 'body',
110110
category: 'test',
111+
threadId: 'thread-id',
111112
fireDate: new Date(new Date().valueOf() + 2000),
112113
repeats: true,
113114
});
@@ -220,6 +221,7 @@ export const App = () => {
220221
`Alert title: ${notification.getTitle()},
221222
Alert subtitle: ${notification.getSubtitle()},
222223
Alert message: ${notification.getMessage()},
224+
Thread Id: ${notification.getThreadID()},
223225
Action Id: ${notification.getActionIdentifier()},
224226
User Text: ${notification.getUserText()},
225227
Notification is clicked: ${String(isClicked)}.`,

index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ export type NotificationRequest = {
159159
* The category of this notification. Required for actionable notifications.
160160
*/
161161
category?: string;
162+
/**
163+
* The thread identifier of this notification.
164+
*/
165+
threadId?: string;
162166
/**
163167
* The date which notification triggers.
164168
*/

ios/RNCPushNotificationIOS.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ + (UNNotificationRequest *)UNNotificationRequest:(id)json
9595
content.body =[RCTConvert NSString:details[@"body"]];
9696
content.badge = [RCTConvert NSNumber:details[@"badge"]];
9797
content.categoryIdentifier = [RCTConvert NSString:details[@"category"]];
98+
99+
NSString* threadIdentifier = [RCTConvert NSString:details[@"threadId"]];
100+
if (threadIdentifier){
101+
content.threadIdentifier = threadIdentifier;
102+
}
103+
98104
content.userInfo = [RCTConvert NSDictionary:details[@"userInfo"]];
99105
if (!isSilent) {
100106
content.sound = [RCTConvert NSString:details[@"sound"]] ? [UNNotificationSound soundNamed:[RCTConvert NSString:details[@"sound"]]] : [UNNotificationSound defaultSound];

js/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ class PushNotificationIOS {
481481
this._alert = nativeNotif.body;
482482
this._title = nativeNotif?.title;
483483
this._subtitle = nativeNotif?.subtitle;
484+
this._threadID = nativeNotif['thread-id'];
484485
this._data = nativeNotif.userInfo;
485486
this._category = nativeNotif.category;
486487
this._fireDate = nativeNotif.fireDate;

js/types.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export type NotificationRequest = {
2828
* The category of this notification. Required for actionable notifications.
2929
*/
3030
category?: string,
31+
/**
32+
* The thread identifier of this notification.
33+
*/
34+
threadId?: string,
3135
/**
3236
* The date which notification triggers.
3337
*/

0 commit comments

Comments
 (0)