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

add ability to set timezone on events in iOS. necessary for recurrenc… #335

Merged
merged 2 commits into from
Dec 17, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ Returns: **Promise**
| [**attendees**](#attendees)\* | Array | The attendees of the event, including the organizer. | ✓ | ✓ |
| [**calendar**](#calendar)\* | Object | The calendar containing the event. | ✓ | ✓ |
| **skipAndroidTimezone** | Bool | Skip the process of setting automatic timezone on android | | ✓ |
| **timeZone** | String | The time zone associated with the event | ✓ | |

### Calendar

Expand Down Expand Up @@ -388,7 +389,7 @@ If you encounter something that is not listed here, try [searching in GitHub iss
This might be related to a sync issue.
You need to be sure that the event you saved is matching what your device will keep in sync.

For iOS, you might have not all event synced. You might need to update this iOS settings in _Settings_ > _Calendar_ > _Sync_ > **All Events**. If that's not enough, it might be worth checking [iOS iCloud sync documentation](https://support.apple.com/en-us/HT203521).
For iOS, you might have not all event synced. You might need to update this iOS settings in _Settings_ > _Calendar_ > _Sync_ > **All Events**. If that's not enough, it might be worth checking [iOS iCloud sync documentation](https://support.apple.com/en-us/HT203521).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For iOS, you might have not all event synced. You might need to update this iOS settings in _Settings_ > _Calendar_ > _Sync_ > **All Events**. If that's not enough, it might be worth checking [iOS iCloud sync documentation](https://support.apple.com/en-us/HT203521).
For iOS, you might have not all event synced. You might need to update this iOS settings in _Settings_ > _Calendar_ > _Sync_ > **All Events**. If that's not enough, it might be worth checking [iOS iCloud sync documentation](https://support.apple.com/en-us/HT203521).

For Android, you can have a look to [Google Calendar sync problems documentation](https://support.google.com/calendar/answer/6261951).

## Wiki
Expand Down
14 changes: 13 additions & 1 deletion ios/RNCalendarEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ @interface RNCalendarEvents ()
static NSString *const _isDetached = @"isDetached";
static NSString *const _availability = @"availability";
static NSString *const _attendees = @"attendees";
static NSString *const _timeZone = @"timeZone";

dispatch_queue_t serialQueue;

@implementation RNCalendarEvents
Expand Down Expand Up @@ -115,6 +117,7 @@ - (NSDictionary *)buildAndSaveEvent:(NSDictionary *)details options:(NSDictionar
NSString *recurrence = [RCTConvert NSString:details[_recurrence]];
NSDictionary *recurrenceRule = [RCTConvert NSDictionary:details[_recurrenceRule]];
NSString *availability = [RCTConvert NSString:details[_availability]];
NSString *timeZone = [RCTConvert NSString:details[_timeZone]];

if (eventId) {
calendarEvent = (EKEvent *)[self.eventStore calendarItemWithIdentifier:eventId];
Expand All @@ -133,6 +136,10 @@ - (NSDictionary *)buildAndSaveEvent:(NSDictionary *)details options:(NSDictionar
}
}

if (timeZone) {
calendarEvent.timeZone = [NSTimeZone timeZoneWithName:timeZone];
}

if (title) {
calendarEvent.title = title;
}
Expand Down Expand Up @@ -501,6 +508,7 @@ - (NSDictionary *)serializeCalendarEvent:(EKEvent *)event
@"endDate": @""
},
_availability: @"",
_timeZone: @""
};

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
Expand Down Expand Up @@ -543,7 +551,11 @@ - (NSDictionary *)serializeCalendarEvent:(EKEvent *)event
if (event.location) {
[formedCalendarEvent setValue:event.location forKey:_location];
}


if (event.timeZone) {
[formedCalendarEvent setValue:event.timeZone forKey:_timeZone];
}

@try {
if (event.attendees) {
NSMutableArray *attendees = [[NSMutableArray alloc] init];
Expand Down
2 changes: 2 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ interface CalendarEventBase {
notes?: string;
/** ANDROID ONLY - The description associated with the calendar event. */
description?: string;
/** iOS ONLY - The time zone associated with the event
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** iOS ONLY - The time zone associated with the event
/** iOS ONLY - The time zone associated with the event. */

timeZone?: string;
}

export interface CalendarEventReadable extends CalendarEventBase {
Expand Down