From a8f429d3a8bb3af4a43570e1b84bc18780cb0830 Mon Sep 17 00:00:00 2001 From: ashoat Date: Wed, 10 Jan 2018 17:40:57 -0800 Subject: [PATCH] Add support for "thread-id" in PushNotificationIOS Summary: `thread-id` is an Apple-defined key. `PushNotificationIOS.getDeliveredNotifications()` includes it, but the notification object currently ignores it. Since it's in the `aps` key, it's impossible to access without this change, as `getData()` does not include it. Closes https://github.com/facebook/react-native/pull/17499 Differential Revision: D6696577 Pulled By: shergin fbshipit-source-id: e0f48efd640bf5addb24a8d4352f9bb23f42612a --- Libraries/PushNotificationIOS/PushNotificationIOS.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Libraries/PushNotificationIOS/PushNotificationIOS.js b/Libraries/PushNotificationIOS/PushNotificationIOS.js index fc09fef39..932011079 100644 --- a/Libraries/PushNotificationIOS/PushNotificationIOS.js +++ b/Libraries/PushNotificationIOS/PushNotificationIOS.js @@ -129,6 +129,7 @@ class PushNotificationIOS { _notificationId: string; _isRemote: boolean; _remoteNotificationCompleteCallbackCalled: boolean; + _threadID: string; static FetchResult: FetchResult = { NewData: 'UIBackgroundFetchResultNewData', @@ -424,6 +425,7 @@ class PushNotificationIOS { this._badgeCount = notifVal.badge; this._category = notifVal.category; this._contentAvailable = notifVal['content-available']; + this._threadID = notifVal['thread-id']; } else { this._data[notifKey] = notifVal; } @@ -451,7 +453,7 @@ class PushNotificationIOS { * If you do not call this method your background remote notifications could * be throttled, to read more about it see the above documentation link. */ - finish(fetchResult: FetchResult) { + finish(fetchResult: string) { if (!this._isRemote || !this._notificationId || this._remoteNotificationCompleteCallbackCalled) { return; } @@ -509,6 +511,13 @@ class PushNotificationIOS { getData(): ?Object { return this._data; } + + /** + * Gets the thread ID on the notif + */ + getThreadID(): ?string { + return this._threadID; + } } module.exports = PushNotificationIOS;