Reputation: 5023
I am trying to make Event Syncing feature for a Project. I need to sync events with the remote server.
eventIdentifier
on the remote database.eventIdentifiers
were as per Device A, there is no way to Identify if the event is already added in Device B or not. Can anyone suggest me the way to achieve such cross-platform event syncing without duplication of the event?
EKEvent has property eventIdentifier
, but it's only readOnly
property and I can't keep event's remote ID somewhere.
Upvotes: 1
Views: 1396
Reputation: 5454
eventIdentifier
is not shared between devices - same event will most likely have different eventIdentifier
on different devices.
Instead, you need to use the calendarItemExternalIdentifier
- this will (generally) be the same on different devices.
One (relatively rare) exception is when an event has been created recently using EventKit, and the event was not yet synced to the server. This causes the calendarItemExternalIdentifier
to change at a later time.
Using calendarItemExternalIdentifier
you can check if an event was already added by querying to see if there's already a record with the same calendarItemExternalIdentifier
in your database. The exception described above needs to be handled separately.
Upvotes: 4