Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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, *)) {
Expand All @@ -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(
Expand Down Expand Up @@ -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) ]);
Expand Down Expand Up @@ -444,7 +444,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
};
}

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];
Expand All @@ -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<NSString *, id> *notificationDict = [RCTConvert NSDictionaryForNotification:notification];
UNNotificationContent *content = [RCTConvert UNNotificationContent:notificationDict];
Expand Down Expand Up @@ -486,7 +486,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
[center addNotificationRequest:request withCompletionHandler:nil];
}

RCT_EXPORT_METHOD(cancelAllLocalNotifications)
- (void)cancelAllLocalNotifications
{
[[UNUserNotificationCenter currentNotificationCenter]
getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> *requests) {
Expand All @@ -499,9 +499,10 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
}];
}

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];
Expand Down Expand Up @@ -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
Expand All @@ -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<UNNotificationRequest *> *_Nonnull requests) {
Expand All @@ -565,23 +565,24 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
}];
}

RCT_EXPORT_METHOD(removeAllDeliveredNotifications)
- (void)removeAllDeliveredNotifications
{
#if !TARGET_OS_TV
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center 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];
Expand All @@ -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) {
Expand Down
Loading