Page MenuHomePhabricator

D7283.id26297.diff
No OneTemporary

D7283.id26297.diff

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

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)

Event Timeline