diff --git a/README.md b/README.md index 9ee00597..8d157acc 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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). For Android, you can have a look to [Google Calendar sync problems documentation](https://support.google.com/calendar/answer/6261951). ## Wiki diff --git a/ios/RNCalendarEvents.m b/ios/RNCalendarEvents.m index 7d0adc8b..c387cd3e 100644 --- a/ios/RNCalendarEvents.m +++ b/ios/RNCalendarEvents.m @@ -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 @@ -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]; @@ -133,6 +136,10 @@ - (NSDictionary *)buildAndSaveEvent:(NSDictionary *)details options:(NSDictionar } } + if (timeZone) { + calendarEvent.timeZone = [NSTimeZone timeZoneWithName:timeZone]; + } + if (title) { calendarEvent.title = title; } @@ -501,6 +508,7 @@ - (NSDictionary *)serializeCalendarEvent:(EKEvent *)event @"endDate": @"" }, _availability: @"", + _timeZone: @"" }; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; @@ -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]; diff --git a/src/index.d.ts b/src/index.d.ts index e425890b..1c133b11 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -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 + timeZone?: string; } export interface CalendarEventReadable extends CalendarEventBase {