Skip to content

feat: add threadIdentifier for local notification #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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)}.`,
Expand Down
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
6 changes: 6 additions & 0 deletions ios/RNCPushNotificationIOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions js/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down