Skip to content

Commit 88b49f9

Browse files
authored
feat: add day of the week and year repetition (#325)
1 parent b28a99c commit 88b49f9

File tree

6 files changed

+30
-13
lines changed

6 files changed

+30
-13
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,13 @@ request is an object containing:
335335

336336
request.repeatsComponent is an object containing (each field is optionnal):
337337

338+
- `year`: Will repeat every selected year in your fireDate.
338339
- `month`: Will repeat every selected month in your fireDate.
339340
- `day`: Will repeat every selected day in your fireDate.
341+
- `dayOfWeek`: Will repeast every selected day of the week in your fireDate.
340342
- `hour`: Will repeat every selected hour in your fireDate.
341343
- `minute`: Will repeat every selected minute in your fireDate.
342344
- `second`: Will repeat every selected second in your fireDate.
343-
- `nanosecond`: Will repeat every selected nanosecond in your fireDate.
344345

345346
For example, let’s say you want to have a notification repeating every day at 23:54, starting tomorrow, you will use something like this:
346347

example/ios/Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ PODS:
332332
- React-cxxreact (= 0.64.2)
333333
- React-jsi (= 0.64.2)
334334
- React-perflogger (= 0.64.2)
335-
- RNCPushNotificationIOS (1.8.0):
335+
- RNCPushNotificationIOS (1.9.0):
336336
- React-Core
337337
- Yoga (1.14.0)
338338
- YogaKit (1.18.1):
@@ -472,17 +472,17 @@ EXTERNAL SOURCES:
472472
SPEC CHECKSUMS:
473473
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
474474
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
475-
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
475+
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
476476
FBLazyVector: e686045572151edef46010a6f819ade377dfeb4b
477-
FBReactNativeSpec: 5f16d334c9fd49a492f4db708f24d207c39bb3ac
477+
FBReactNativeSpec: 671da7bdb2a22799bfef695306097397b129ab9e
478478
Flipper: d3da1aa199aad94455ae725e9f3aa43f3ec17021
479479
Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41
480480
Flipper-Folly: 755929a4f851b2fb2c347d533a23f191b008554c
481481
Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6
482482
Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9
483483
Flipper-RSocket: 127954abe8b162fcaf68d2134d34dc2bd7076154
484484
FlipperKit: 8a20b5c5fcf9436cac58551dc049867247f64b00
485-
glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62
485+
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
486486
hermes-engine: 7d97ba46a1e29bacf3e3c61ecb2804a5ddd02d4f
487487
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
488488
OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b
@@ -509,7 +509,7 @@ SPEC CHECKSUMS:
509509
React-RCTVibration: 24600e3b1aaa77126989bc58b6747509a1ba14f3
510510
React-runtimeexecutor: a9904c6d0218fb9f8b19d6dd88607225927668f9
511511
ReactCommon: 149906e01aa51142707a10665185db879898e966
512-
RNCPushNotificationIOS: 61a7c72bd1ebad3568025957d001e0f0e7b32191
512+
RNCPushNotificationIOS: 5bffde624d1fd15bfc8b2fd202b012a517a6dc9b
513513
Yoga: 575c581c63e0d35c9a83f4b46d01d63abc1100ac
514514
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
515515

example/ios/example.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@
560560
COPY_PHASE_STRIP = NO;
561561
ENABLE_STRICT_OBJC_MSGSEND = YES;
562562
ENABLE_TESTABILITY = YES;
563-
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 i386";
563+
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
564564
GCC_C_LANGUAGE_STANDARD = gnu99;
565565
GCC_DYNAMIC_NO_PIC = NO;
566566
GCC_NO_COMMON_BLOCKS = YES;
@@ -625,7 +625,7 @@
625625
COPY_PHASE_STRIP = YES;
626626
ENABLE_NS_ASSERTIONS = NO;
627627
ENABLE_STRICT_OBJC_MSGSEND = YES;
628-
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 i386";
628+
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
629629
GCC_C_LANGUAGE_STANDARD = gnu99;
630630
GCC_NO_COMMON_BLOCKS = YES;
631631
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;

index.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,19 @@ export type NotificationRequest = {
174174
* Must be used with fireDate.
175175
*/
176176
repeats?: boolean;
177+
/**
178+
* Define what components should be used in the fireDate during repeats.
179+
* Must be used with repeats and fireDate.
180+
*/
181+
repeatsComponent?: {
182+
year?: boolean;
183+
month?: boolean;
184+
day?: boolean;
185+
dayOfWeek?: boolean;
186+
hour?: boolean;
187+
minute?: boolean;
188+
second?: boolean;
189+
};
177190
/**
178191
* Sets notification to be silent
179192
*/

ios/RCTConvert+Notification.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,13 @@ + (UNNotificationRequest *)UNNotificationRequest:(id)json
112112
}
113113

114114
NSDictionary<NSString *, id> *userDateComps = [RCTConvert NSDictionary:details[@"repeatsComponent"]];
115+
BOOL year = [RCTConvert BOOL:userDateComps[@"year"]];
115116
BOOL month = [RCTConvert BOOL:userDateComps[@"month"]];
116117
BOOL day = [RCTConvert BOOL:userDateComps[@"day"]];
118+
BOOL dayOfWeek = [RCTConvert BOOL:userDateComps[@"dayOfWeek"]];
117119
BOOL hour = [RCTConvert BOOL:userDateComps[@"hour"]];
118120
BOOL minute = [RCTConvert BOOL:userDateComps[@"minute"]];
119121
BOOL second = [RCTConvert BOOL:userDateComps[@"second"]];
120-
BOOL nanosecond = [RCTConvert BOOL:userDateComps[@"nanosecond"]];
121122

122123
content.userInfo = [RCTConvert NSDictionary:details[@"userInfo"]];
123124
if (!isSilent) {
@@ -129,7 +130,7 @@ + (UNNotificationRequest *)UNNotificationRequest:(id)json
129130
}
130131
} else {
131132
content.sound = [RCTConvert NSString:details[@"sound"]] ? [UNNotificationSound soundNamed:[RCTConvert NSString:details[@"sound"]]] : [UNNotificationSound defaultSound];
132-
}```
133+
}
133134
}
134135

135136
NSDate* fireDate = [RCTConvert NSDate:details[@"fireDate"]];
@@ -142,12 +143,13 @@ + (UNNotificationRequest *)UNNotificationRequest:(id)json
142143
NSCalendarUnitMinute |
143144
NSCalendarUnitSecond;
144145
NSCalendarUnit repeatDateComponents =
146+
(year ? NSCalendarUnitYear : 0) |
145147
(month ? NSCalendarUnitMonth : 0) |
146148
(day ? NSCalendarUnitDay : 0) |
149+
(dayOfWeek ? NSCalendarUnitWeekday : 0) |
147150
(hour ? NSCalendarUnitHour : 0) |
148151
(minute ? NSCalendarUnitMinute : 0) |
149-
(second ? NSCalendarUnitSecond : 0) |
150-
(nanosecond ? NSCalendarUnitNanosecond : 0);
152+
(second ? NSCalendarUnitSecond : 0);
151153
NSDateComponents *triggerDate = fireDate
152154
? [[NSCalendar currentCalendar]
153155
components:(repeats ? repeatDateComponents : defaultDateComponents) | NSCalendarUnitTimeZone

js/types.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ export type NotificationRequest = {|
5050
* Must be used with repeats and fireDate.
5151
*/
5252
repeatsComponent?: {
53+
year?: boolean,
5354
month?: boolean,
5455
day?: boolean,
56+
dayOfWeek?: boolean,
5557
hour?: boolean,
5658
minute?: boolean,
5759
second?: boolean,
58-
nanosecond?: boolean,
5960
},
6061
/**
6162
* Sets notification to be silent

0 commit comments

Comments
 (0)