diff --git a/ios/RNCPushNotificationIOS.m b/ios/RNCPushNotificationIOS.m index ca683648..813cfa7f 100644 --- a/ios/RNCPushNotificationIOS.m +++ b/ios/RNCPushNotificationIOS.m @@ -286,7 +286,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification [RCTSharedApplication() scheduleLocalNotification:notification]; } -RCT_EXPORT_METHOD(addNotificationRequest:(UNNotificationRequest*)request) +RCT_EXPORT_METHOD(addNotificationRequest:(UNNotificationRequest*)request callback:(RCTResponseSenderBlock)callback) { UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; NSString *imageUrl = request.content.userInfo[@"image"]; @@ -306,6 +306,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification if (!error) { NSLog(@"image notifier request success"); } + callback(error); } ]; } @@ -316,6 +317,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification if (!error) { NSLog(@"notifier request success"); } + callback(error); } ]; } diff --git a/js/index.js b/js/index.js index b2cd9502..924efd68 100644 --- a/js/index.js +++ b/js/index.js @@ -141,7 +141,7 @@ class PushNotificationIOS { * Sends notificationRequest to notification center at specified firedate. * Fires immediately if firedate is not set. */ - static addNotificationRequest(request: NotificationRequest) { + static addNotificationRequest(request: NotificationRequest, callback: Function = () =>{}) { const handledRequest = request.fireDate instanceof Date ? {...request, fireDate: request.fireDate.toISOString()} @@ -151,7 +151,7 @@ class PushNotificationIOS { repeatsComponent: request.repeatsComponent || {}, }; - RNCPushNotificationIOS.addNotificationRequest(finalRequest); + RNCPushNotificationIOS.addNotificationRequest(finalRequest, callback); } /**