Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3727793
D7283.id26297.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D7283.id26297.diff
View Options
diff --git a/native/ios/Comm/CommIOSNotifications/CommIOSNotifications.h b/native/ios/Comm/CommIOSNotifications/CommIOSNotifications.h
--- a/native/ios/Comm/CommIOSNotifications/CommIOSNotifications.h
+++ b/native/ios/Comm/CommIOSNotifications/CommIOSNotifications.h
@@ -15,6 +15,7 @@
+ (void)didReceiveRemoteNotification:(NSDictionary *)notification
fetchCompletionHandler:
(void (^)(UIBackgroundFetchResult))completionHandler;
++ (void)didReceiveBackgroundMessageInfos:(NSDictionary *)notification;
+ (void)clearNotificationFromNotificationsCenter:(NSString *)notificationId
completionHandler:
(void (^)(UIBackgroundFetchResult))
diff --git a/native/ios/Comm/CommIOSNotifications/CommIOSNotifications.mm b/native/ios/Comm/CommIOSNotifications/CommIOSNotifications.mm
--- a/native/ios/Comm/CommIOSNotifications/CommIOSNotifications.mm
+++ b/native/ios/Comm/CommIOSNotifications/CommIOSNotifications.mm
@@ -18,6 +18,8 @@
NSString *const CommIOSNotificationsReceivedForeground =
@"CommIOSNotificationsReceivedForeground";
NSString *const CommIOSNotificationsOpened = @"CommIOSNotificationsOpened";
+NSString *const CommIOSNotificationsReceivedBackground =
+ @"CommIOSNotificationsReceivedBackground";
/*
UIBackgroundFetchResult enum converter to pass fetch result value
@@ -88,6 +90,11 @@
selector:@selector(handleNotificationOpened:)
name:CommIOSNotificationsOpened
object:nil];
+ [NSNotificationCenter.defaultCenter
+ addObserver:self
+ selector:@selector(handleNotificationReceivedBackground:)
+ name:CommIOSNotificationsReceivedBackground
+ object:nil];
return self;
}
@@ -100,7 +107,8 @@
@"remoteNotificationsRegistered",
@"remoteNotificationsRegistrationFailed",
@"notificationReceivedForeground",
- @"notificationOpened"
+ @"notificationOpened",
+ @"notificationReceivedBackground",
];
}
@@ -171,6 +179,13 @@
}
}
++ (void)didReceiveBackgroundMessageInfos:(NSDictionary *)notification {
+ [NSNotificationCenter.defaultCenter
+ postNotificationName:CommIOSNotificationsReceivedBackground
+ object:self
+ userInfo:notification];
+}
+
+ (void)clearNotificationFromNotificationsCenter:(NSString *)notificationId
completionHandler:
(void (^)(UIBackgroundFetchResult))
@@ -249,6 +264,14 @@
[self handleNotifInfo:sysNotif.userInfo withName:@"notificationOpened"];
}
+- (void)handleNotificationReceivedBackground:(NSNotification *)sysNotif {
+ if (!_hasListeners) {
+ return;
+ }
+ [self sendEventWithName:@"notificationReceivedBackground"
+ body:sysNotif.userInfo];
+}
+
/*
Helper methods
*/
diff --git a/native/push/ios.js b/native/push/ios.js
--- a/native/push/ios.js
+++ b/native/push/ios.js
@@ -72,6 +72,7 @@
remoteNotificationsRegistrationFailed: [void],
notificationReceivedForeground: [CoreIOSNotificationData],
notificationOpened: [CoreIOSNotificationData],
+ notificationReceivedBackground: [{ +messageInfos: ?string }],
}>,
> {
return new NativeEventEmitter(CommIOSNotifications);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 9, 9:12 PM (12 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2826755
Default Alt Text
D7283.id26297.diff (3 KB)
Attached To
Mode
D7283: Extend CommIOSNotification module with method to send an event to JS to trigger message infos persistence
Attached
Detach File
Event Timeline
Log In to Comment