Skip to content

Add threadIdentifier to local notifications #41

@holden-caulfield

Description

@holden-caulfield

Feature Request

Add the possibility for local notifications (e.g. as in PushNotificationIOS.presentLocalNotification()) to include threadIdentifier on its details.

Why it is needed

Using the threadIdentifier allows to group notifications together on the notification center

Possible implementation

I'm happy to send a PR, it seems to me it should be as simple as adding the parsing of that parameter on the UILocalNotification object. This would be an iOS only property

@implementation RCTConvert (UILocalNotification)

+ (UILocalNotification *)UILocalNotification:(id)json
{
  NSDictionary<NSString *, id> *details = [self NSDictionary:json];
  ....
  if (details[@"threadIdentifier"]) {
    notification.threadIdentifier = [RCTConvert NSString:details[@"threadIdentifier"]];
  }
  return notification;
}

(Adding the if statement because I guess that if not explicitly set, iOS sets a "smart" threadIdentifier based on application, title, etc.)

Code sample

PushNotificationIOS.presentLocalNotification({
// should also work with PushNotificationIOS.scheduleLocalNotification
   alertTitle: "My threaded local notification"
   alertBody: "This will be threaded",
   threadIdentifier: "SomeIdentifier"
})

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions