Page MenuHomePhabricator

D6072.diff
No OneTemporary

D6072.diff

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
@@ -301,6 +301,25 @@
completionHandler:authorizationRequestCompletionHandler];
}
+RCT_EXPORT_METHOD(completeNotif
+ : (NSString *)completionKey fetchResult
+ : (UIBackgroundFetchResult)result) {
+ RCTRemoteNotificationCallback completionHandler =
+ self.remoteNotificationCallbacks[completionKey];
+ if (!completionHandler) {
+ NSLog(@"There is no completion handler with key: %@", completionKey);
+ return;
+ }
+ completionHandler(result);
+ [self.remoteNotificationCallbacks removeObjectForKey:completionKey];
+}
+
+RCT_EXPORT_METHOD(setBadgesCount : (int)count) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [[UIApplication sharedApplication] setApplicationIconBadgeNumber:count];
+ });
+}
+
RCT_EXPORT_METHOD(consumeBackgroundQueue) {
CommIOSNotificationsBridgeQueue.sharedInstance.jsReady = YES;
@@ -344,4 +363,37 @@
}];
}
+RCT_EXPORT_METHOD(removeAllDeliveredNotifications) {
+ [UNUserNotificationCenter
+ .currentNotificationCenter removeAllDeliveredNotifications];
+}
+
+RCT_EXPORT_METHOD(removeDeliveredNotifications
+ : (NSArray<NSString *> *)identifiers) {
+ [UNUserNotificationCenter.currentNotificationCenter
+ removeDeliveredNotificationsWithIdentifiers:identifiers];
+}
+RCT_EXPORT_METHOD(getDeliveredNotifications
+ : (RCTResponseSenderBlock)callback) {
+ [UNUserNotificationCenter.currentNotificationCenter
+ getDeliveredNotificationsWithCompletionHandler:^(
+ NSArray<UNNotification *> *_Nonnull notifications) {
+ NSMutableArray<NSDictionary *> *formattedNotifications =
+ [NSMutableArray new];
+
+ for (UNNotification *notification in notifications) {
+ NSDictionary *jsReadableNotification = [CommIOSNotifications
+ parseNotificationToJSReadableObject:notification.request.content
+ .userInfo
+ withRequestIdentifier:notification.request
+ .identifier];
+ if (!jsReadableNotification) {
+ continue;
+ }
+ [formattedNotifications addObject:jsReadableNotification];
+ }
+ callback(@[ formattedNotifications ]);
+ }];
+}
+
@end

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 16, 9:22 AM (21 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2497120
Default Alt Text
D6072.diff (2 KB)

Event Timeline