From 9a8b5fcf6186e966185bb4b91ec2e0e758621648 Mon Sep 17 00:00:00 2001 From: Connor McEwen Date: Tue, 11 Oct 2016 07:39:48 -0700 Subject: [PATCH] Add repeatInterval to PushNotificationIOS Summary: This just cleans up the work done in #7219 by adamterlson based on grabbou's feedback Closes https://github.com/facebook/react-native/pull/10337 Differential Revision: D4001540 Pulled By: javache fbshipit-source-id: c73b5fef912fa71d1d988dae41094c9c46dc610b --- .../PushNotificationIOS/PushNotificationIOS.js | 1 + .../RCTPushNotificationManager.m | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Libraries/PushNotificationIOS/PushNotificationIOS.js b/Libraries/PushNotificationIOS/PushNotificationIOS.js index cdfeafbc45cae9..7d3f7e9fa47dee 100644 --- a/Libraries/PushNotificationIOS/PushNotificationIOS.js +++ b/Libraries/PushNotificationIOS/PushNotificationIOS.js @@ -135,6 +135,7 @@ class PushNotificationIOS { * - `category` : The category of this notification, required for actionable notifications (optional). * - `userInfo` : An optional object containing additional notification data. * - `applicationIconBadgeNumber` (optional) : The number to display as the app's icon badge. Setting the number to 0 removes the icon badge. + * - `repeatInterval` : The interval to repeat as a string. Possible values: `minute`, `hour`, `day`, `week`, `month`, `year`. */ static scheduleLocalNotification(details: Object) { RCTPushNotificationManager.scheduleLocalNotification(details); diff --git a/Libraries/PushNotificationIOS/RCTPushNotificationManager.m b/Libraries/PushNotificationIOS/RCTPushNotificationManager.m index e4ad7d864da71d..ead711bf409e92 100644 --- a/Libraries/PushNotificationIOS/RCTPushNotificationManager.m +++ b/Libraries/PushNotificationIOS/RCTPushNotificationManager.m @@ -22,6 +22,22 @@ NSString *const RCTErrorUnableToRequestPermissions = @"E_UNABLE_TO_REQUEST_PERMISSIONS"; NSString *const RCTErrorRemoteNotificationRegistrationFailed = @"E_FAILED_TO_REGISTER_FOR_REMOTE_NOTIFICATIONS"; +@implementation RCTConvert (NSCalendarUnit) + +RCT_ENUM_CONVERTER(NSCalendarUnit, + (@{ + @"year": @(NSCalendarUnitYear), + @"month": @(NSCalendarUnitMonth), + @"week": @(NSCalendarUnitWeekOfYear), + @"day": @(NSCalendarUnitDay), + @"hour": @(NSCalendarUnitHour), + @"minute": @(NSCalendarUnitMinute) + }), + 0, + integerValue) + +@end + @implementation RCTConvert (UILocalNotification) + (UILocalNotification *)UILocalNotification:(id)json @@ -34,6 +50,7 @@ + (UILocalNotification *)UILocalNotification:(id)json notification.soundName = [RCTConvert NSString:details[@"soundName"]] ?: UILocalNotificationDefaultSoundName; notification.userInfo = [RCTConvert NSDictionary:details[@"userInfo"]]; notification.category = [RCTConvert NSString:details[@"category"]]; + notification.repeatInterval = [RCTConvert NSCalendarUnit:details[@"repeatInterval"]]; if (details[@"applicationIconBadgeNumber"]) { notification.applicationIconBadgeNumber = [RCTConvert NSInteger:details[@"applicationIconBadgeNumber"]]; }