EddyVerbruggen / Calendar-PhoneGap-Plugin

:date: Cordova plugin to Create, Change, Delete and Find Events in the native Calendar
774 stars 403 forks source link

Implementation of the feature to add attendees (email) interactively and silently at the event creation. #529

Open paolocarrara opened 4 years ago

paolocarrara commented 4 years ago

Hi, here is the feature I said I was going to work with.

With this pull request users will be able to add attendees to events passing the "attendees" option key in the options object. The value of this key must be an array of strings, those strings must be the participants e-mails. Interactively, silently, with and without options, everything worked just fine.

I tested on my iPhone 8 with iOS version 13.3.1 and on a Samsung Galaxy A10 with Android version 9.

Please review my changes and let me know if there is anything else I can do to make this feature come to main line.

Thanks!

DaveLomber commented 1 year ago

Getting this error when press Add button

2022-10-25 13:23:53.761188+0300 MyApp[3773:606305] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil'
andrerds commented 10 months ago

Folks,

I'm thrilled to share the breakthrough I achieved after days of extensive research.

The challenge I was facing revolved around missing or incorrect information. In earlier iOS versions, this issue might not have been as noticeable, possibly because it seemed to be disregarded. However, with iOS 16, I discovered that providing a valid UUID (Universally Unique Identifier) was crucial.

After implementing the addition of a unique UUID for each attendee, I witnessed a successful resolution without any unwanted crashes. I had the opportunity to test this on the iPhone X running iOS 16.5.

Here's the solution I adopted:

NSMutableArray *attendeesObjectsList = [NSMutableArray new]; if (attendees != (id)[NSNull null]) { NSUInteger size = [attendees count]; for (int i = 0; i < size; i++) { Class className = NSClassFromString(@"EKAttendee"); id attendee = [className new]; NSUUID *uuid = [NSUUID UUID]; NSString *uuidString = [uuid UUIDString]; [attendee setValue:uuidString forKey:@"UUID"]; [attendee setValue:[NSString stringWithFormat:@"%@", [attendees objectAtIndex:i]] forKey:@"emailAddress"]; [attendeesObjectsList addObject:attendee]; } [myEvent setValue:attendeesObjectsList forKey:@"attendees"]; }

I hope this also proves helpful to you.