diff --git a/packages/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm b/packages/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm index d5c6bc7270a..963edd3edcb 100644 --- a/packages/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm +++ b/packages/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm @@ -305,7 +305,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification [self sendEventWithName:@"remoteNotificationRegistrationError" body:errorDetails]; } -RCT_EXPORT_METHOD(onFinishRemoteNotification : (NSString *)notificationId fetchResult : (NSString *)fetchResult) +- (void)onFinishRemoteNotification:(NSString *)notificationId fetchResult:(NSString *)fetchResult { UIBackgroundFetchResult result = [RCTConvert UIBackgroundFetchResult:fetchResult]; RCTRemoteNotificationCallback completionHandler = self.remoteNotificationCallbacks[notificationId]; @@ -320,7 +320,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification /** * Update the application icon badge number on the home screen */ -RCT_EXPORT_METHOD(setApplicationIconBadgeNumber : (double)number) +- (void)setApplicationIconBadgeNumber:(double)number { NSInteger badgeCount = (NSInteger)lround(number); if (@available(iOS 16.0, *)) { @@ -339,14 +339,14 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification /** * Get the current application icon badge number on the home screen */ -RCT_EXPORT_METHOD(getApplicationIconBadgeNumber : (RCTResponseSenderBlock)callback) +- (void)getApplicationIconBadgeNumber:(RCTResponseSenderBlock)callback { callback(@[ @(RCTSharedApplication().applicationIconBadgeNumber) ]); } -RCT_EXPORT_METHOD( - requestPermissions : (JS::NativePushNotificationManagerIOS::SpecRequestPermissionsPermission &) - permissions resolve : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject) +- (void)requestPermissions:(JS::NativePushNotificationManagerIOS::SpecRequestPermissionsPermission &)permissions + resolve:(RCTPromiseResolveBlock)resolve + reject:(RCTPromiseRejectBlock)reject { if (RCTRunningInAppExtension()) { reject( @@ -389,12 +389,12 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification }]; } -RCT_EXPORT_METHOD(abandonPermissions) +- (void)abandonPermissions { [RCTSharedApplication() unregisterForRemoteNotifications]; } -RCT_EXPORT_METHOD(checkPermissions : (RCTResponseSenderBlock)callback) +- (void)checkPermissions:(RCTResponseSenderBlock)callback { if (RCTRunningInAppExtension()) { callback(@[ RCTSettingsDictForUNNotificationSettings(NO, NO, NO, NO, NO, NO, UNAuthorizationStatusNotDetermined) ]); @@ -444,7 +444,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification }; } -RCT_EXPORT_METHOD(presentLocalNotification : (JS::NativePushNotificationManagerIOS::Notification &)notification) +- (void)presentLocalNotification:(JS::NativePushNotificationManagerIOS::Notification &)notification { NSDictionary *notificationDict = [RCTConvert NSDictionaryForNotification:notification]; UNNotificationContent *content = [RCTConvert UNNotificationContent:notificationDict]; @@ -458,7 +458,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification [center addNotificationRequest:request withCompletionHandler:nil]; } -RCT_EXPORT_METHOD(scheduleLocalNotification : (JS::NativePushNotificationManagerIOS::Notification &)notification) +- (void)scheduleLocalNotification:(JS::NativePushNotificationManagerIOS::Notification &)notification { NSDictionary *notificationDict = [RCTConvert NSDictionaryForNotification:notification]; UNNotificationContent *content = [RCTConvert UNNotificationContent:notificationDict]; @@ -486,7 +486,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification [center addNotificationRequest:request withCompletionHandler:nil]; } -RCT_EXPORT_METHOD(cancelAllLocalNotifications) +- (void)cancelAllLocalNotifications { [[UNUserNotificationCenter currentNotificationCenter] getPendingNotificationRequestsWithCompletionHandler:^(NSArray *requests) { @@ -499,9 +499,10 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification }]; } -RCT_EXPORT_METHOD(cancelLocalNotifications : (NSDictionary *)userInfo) +- (void)cancelLocalNotifications:(NSDictionary *)userInfoRaw { #if !TARGET_OS_TV + NSDictionary *userInfo = [RCTConvert NSDictionary:userInfoRaw]; UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center getPendingNotificationRequestsWithCompletionHandler:^(NSArray *_Nonnull requests) { NSMutableArray *notificationIdentifiersToCancel = [NSMutableArray new]; @@ -529,8 +530,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification #endif } -RCT_EXPORT_METHOD( - getInitialNotification : (RCTPromiseResolveBlock)resolve reject : (__unused RCTPromiseRejectBlock)reject) +- (void)getInitialNotification:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject { // The user actioned a local or remote notification to launch the app. Notification is represented by UNNotification. // Set this property in the implementation of @@ -553,7 +553,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification resolve((id)kCFNull); } -RCT_EXPORT_METHOD(getScheduledLocalNotifications : (RCTResponseSenderBlock)callback) +- (void)getScheduledLocalNotifications:(RCTResponseSenderBlock)callback { UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center getPendingNotificationRequestsWithCompletionHandler:^(NSArray *_Nonnull requests) { @@ -565,7 +565,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification }]; } -RCT_EXPORT_METHOD(removeAllDeliveredNotifications) +- (void)removeAllDeliveredNotifications { #if !TARGET_OS_TV UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; @@ -573,15 +573,16 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification #endif } -RCT_EXPORT_METHOD(removeDeliveredNotifications : (NSArray *)identifiers) +- (void)removeDeliveredNotifications:(NSArray *)identifiersRaw { #if !TARGET_OS_TV + NSArray *identifiers = [RCTConvert NSStringArray:identifiersRaw]; UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center removeDeliveredNotificationsWithIdentifiers:identifiers]; #endif } -RCT_EXPORT_METHOD(getDeliveredNotifications : (RCTResponseSenderBlock)callback) +- (void)getDeliveredNotifications:(RCTResponseSenderBlock)callback { #if !TARGET_OS_TV UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; @@ -598,7 +599,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification #endif } -RCT_EXPORT_METHOD(getAuthorizationStatus : (RCTResponseSenderBlock)callback) +- (void)getAuthorizationStatus:(RCTResponseSenderBlock)callback { UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings *_Nonnull settings) {