Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make notifications time zone agnostic #354

Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ request is an object containing:
- `isCritical` : If true, the notification sound be played even when the device is locked, muted, or has Do Not Disturb enabled.
- `criticalSoundVolume` : A number between 0 and 1 for volume of critical notification. Default volume will be used if not specified.
- `userInfo` : An object containing additional notification data.
- `isTimeZoneAgnostic` : If true, fireDate adjusted automatically upon time zone changes (e.g. for an alarm clock).

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

Expand Down
4 changes: 4 additions & 0 deletions ios/RCTConvert+Notification.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ + (UILocalNotification *)UILocalNotification:(id)json
{
NSDictionary<NSString *, id> *details = [self NSDictionary:json];
BOOL isSilent = [RCTConvert BOOL:details[@"isSilent"]];
BOOL isTimeZoneAgnostic = [RCTConvert BOOL:details[@"isTimeZoneAgnostic"]];
UILocalNotification *notification = [UILocalNotification new];
notification.alertTitle = [RCTConvert NSString:details[@"alertTitle"]];
notification.fireDate = [RCTConvert NSDate:details[@"fireDate"]] ?: [NSDate date];
Expand All @@ -49,6 +50,9 @@ + (UILocalNotification *)UILocalNotification:(id)json
if (!isSilent) {
notification.soundName = [RCTConvert NSString:details[@"soundName"]] ?: UILocalNotificationDefaultSoundName;
}
if (isTimeZoneAgnostic) {
notification.timeZone = [NSTimeZone defaultTimeZone];
}
return notification;
}

Expand Down
4 changes: 4 additions & 0 deletions js/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export type NotificationRequest = {|
* Optional data to be added to the notification
*/
userInfo?: Object,
/**
* FireDate adjusted automatically upon time zone changes (e.g. for an alarm clock).
*/
isTimeZoneAgnostic?: boolean,
|};

/**
Expand Down