Permalink
Browse files

Add repeatInterval to PushNotificationIOS

Summary:
This just cleans up the work done in #7219 by adamterlson based on grabbou's feedback
Closes #10337

Differential Revision: D4001540

Pulled By: javache

fbshipit-source-id: c73b5fef912fa71d1d988dae41094c9c46dc610b
  • Loading branch information...
1 parent 0f3d24c commit 9a8b5fcf6186e966185bb4b91ec2e0e758621648 @cmcewen cmcewen committed with Facebook Github Bot Oct 11, 2016
@@ -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);
@@ -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"]];
}

0 comments on commit 9a8b5fc

Please sign in to comment.