xplat/js/react-native-github/packages/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm (#57833)

Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57833

...Actions taken:
1. Ran build_codegen_spec to generate the FBReactNativeSpec protocol and located/read the `NativePushNotificationManagerIOSSpec` protocol.
2. Ran apply_cast_mod, which mechanically converted all clean methods and flagged two `type-mismatch` methods.
3. Hand-reconciled `cancelLocalNotifications:` and `removeDeliveredNotifications:` by moving to the spec's exact parameter types and restoring the implicit `RCTConvert` coercion in the body.
4. Ran buck_build_verify (BUILD SUCCEEDED) and Lint (no lints). Verified no `RCT_EXPORT_METHOD`/`RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD` macros remain.
</summary>
</invoke>

_____

* Do **NOT** post in the CodemodService Feedback group about this specific diff.
* If you have feedback, comment on the diff and use an appropriate diff action.

This [diff was created](https://www.internalfb.com/intern/sandcastle/job/18014401344983091/) with [CodemodService](https://www.internalfb.com/codemod_service/CodemodConfigDevmateDropRctExportMethod).

Reviewed By: cortinico, christophpurrer

Differential Revision: D114840928

fbshipit-source-id: c13a55fbd11ae5d71d8f0a8fe4c596d7351a4426
This commit is contained in:
generatedunixname1612842167096234 authored and meta-codesync[bot] committed 2026-08-08 19:15:56 -07:00
1 parent 6d34b7aaff
commit db662caead
1 file changed
+20 -19
@@ -305,7 +305,7 @@ RCT_EXPORT_MODULE()
[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 @@ RCT_EXPORT_METHOD(onFinishRemoteNotification : (NSString *)notificationId fetchR
/**
* 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 @@ RCT_EXPORT_METHOD(setApplicationIconBadgeNumber : (double)number)
/**
* 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 @@ RCT_EXPORT_METHOD(
}];
}
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 @@ static inline NSDictionary *RCTSettingsDictForUNNotificationSettings(
};
}
RCT_EXPORT_METHOD(presentLocalNotification : (JS::NativePushNotificationManagerIOS::Notification &)notification)
- (void)presentLocalNotification:(JS::NativePushNotificationManagerIOS::Notification &)notification
{
NSDictionary<NSString *, id> *notificationDict = [RCTConvert NSDictionaryForNotification:notification];
UNNotificationContent *content = [RCTConvert UNNotificationContent:notificationDict];
@@ -458,7 +458,7 @@ RCT_EXPORT_METHOD(presentLocalNotification : (JS::NativePushNotificationManagerI
[center addNotificationRequest:request withCompletionHandler:nil];
}
RCT_EXPORT_METHOD(scheduleLocalNotification : (JS::NativePushNotificationManagerIOS::Notification &)notification)
- (void)scheduleLocalNotification:(JS::NativePushNotificationManagerIOS::Notification &)notification
{
NSDictionary<NSString *, id> *notificationDict = [RCTConvert NSDictionaryForNotification:notification];
UNNotificationContent *content = [RCTConvert UNNotificationContent:notificationDict];
@@ -486,7 +486,7 @@ RCT_EXPORT_METHOD(scheduleLocalNotification : (JS::NativePushNotificationManager
[center addNotificationRequest:request withCompletionHandler:nil];
}
RCT_EXPORT_METHOD(cancelAllLocalNotifications)
- (void)cancelAllLocalNotifications
{
[[UNUserNotificationCenter currentNotificationCenter]
getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> *requests) {
@@ -499,9 +499,10 @@ RCT_EXPORT_METHOD(cancelAllLocalNotifications)
}];
}
RCT_EXPORT_METHOD(cancelLocalNotifications : (NSDictionary<NSString *, id> *)userInfo)
- (void)cancelLocalNotifications:(NSDictionary *)userInfoRaw
{
#if !TARGET_OS_TV
NSDictionary<NSString *, id> *userInfo = [RCTConvert NSDictionary:userInfoRaw];
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> *_Nonnull requests) {
NSMutableArray<NSString *> *notificationIdentifiersToCancel = [NSMutableArray new];
@@ -529,8 +530,7 @@ RCT_EXPORT_METHOD(cancelLocalNotifications : (NSDictionary<NSString *, id> *)use
#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 @@ RCT_EXPORT_METHOD(
resolve((id)kCFNull);
}
RCT_EXPORT_METHOD(getScheduledLocalNotifications : (RCTResponseSenderBlock)callback)
- (void)getScheduledLocalNotifications:(RCTResponseSenderBlock)callback
{
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> *_Nonnull requests) {
@@ -565,7 +565,7 @@ RCT_EXPORT_METHOD(getScheduledLocalNotifications : (RCTResponseSenderBlock)callb
}];
}
RCT_EXPORT_METHOD(removeAllDeliveredNotifications)
- (void)removeAllDeliveredNotifications
{
#if !TARGET_OS_TV
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
@@ -573,15 +573,16 @@ RCT_EXPORT_METHOD(removeAllDeliveredNotifications)
#endif
}
RCT_EXPORT_METHOD(removeDeliveredNotifications : (NSArray<NSString *> *)identifiers)
- (void)removeDeliveredNotifications:(NSArray *)identifiersRaw
{
#if !TARGET_OS_TV
NSArray<NSString *> *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 @@ RCT_EXPORT_METHOD(getDeliveredNotifications : (RCTResponseSenderBlock)callback)
#endif
}
RCT_EXPORT_METHOD(getAuthorizationStatus : (RCTResponseSenderBlock)callback)
- (void)getAuthorizationStatus:(RCTResponseSenderBlock)callback
{
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings *_Nonnull settings) {