Why is my .ics file not registering a cancel event

2019-09-10 22:47发布

问题:

Our application programmatically spits out an .ics file for events. This is what the initial .ics file that gets emailed out looks like, when an event is originally confirmed:

BEGIN:VCALENDAR
BEGIN:VTIMEZONE
METHOD:REQUEST
TZID:America/New_York
TZURL:http://tzurl.org/zoneinfo-outlook/America/New_York
X-LIC-LOCATION:America/New_York
END:VTIMEZONE
BEGIN:VEVENT
UID:test-7-oct-24-2016-uid
DTSTAMP:20161024T181901
ORGANIZER;CN=Host:mailto:fake1@email.com
ATTENDEE;CN=Guest:mailto:fake2@email.com
DTSTART;TZID=America/New_York:20170103T073000
DTEND;TZID=America/New_York:20170103T093000
SUMMARY:Insert random summary
GEO:0;0
DESCRIPTION:Random event
LOCATION:Random Location
SEQUENCE: 0
STATUS: CONFIRMED
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR

This also seems to randomly prompt a menu on Apple's calendar whether or not I want to add the event to my calendar. Sometimes it shows that prompt, other times it doesn't. Not exactly sure why that is.

Anyway, we then send out the 2nd .ics file when the event is cancelled:

BEGIN:VCALENDAR
BEGIN:VTIMEZONE
METHOD:CANCEL
TZID:America/New_York
TZURL:http://tzurl.org/zoneinfo-outlook/America/New_York
X-LIC-LOCATION:America/New_York
END:VTIMEZONE
BEGIN:VEVENT
UID:test-7-oct-24-2016-uid
DTSTAMP:20161024T181901
ORGANIZER;CN=Host:mailto:fake1@email.com
ATTENDEE;CN=Guest:mailto:fake2@email.com
DTSTART;TZID=America/New_York:20170103T073000
DTEND;TZID=America/New_York:20170103T093000
SUMMARY:Insert random summary
GEO:0;0
DESCRIPTION:Random event
LOCATION:Random Location
SEQUENCE: 1
STATUS: CANCELLED
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR

This doesn't end up cancelling the event in my calendar app. Not sure what's going on here. Does anyone know where I'm going wrong in this ics file?

回答1:

Your METHOD property which indicates the type of iTIP message is included in the VTIMEZONE definition so it probably ends up being totally ignored by the client. The METHOD should appear before the VTIMEZONE.

In other words, you should have:

BEGIN:VCALENDAR
METHOD:REQUEST
BEGIN:VTIMEZONE
...

instead of

BEGIN:VCALENDAR
BEGIN:VTIMEZONE
METHOD:REQUEST
...

This is also true for your CANCEL.

There might be other issues of course.



回答2:

If we would refer to Using the iCalendar Format, events save in .ics file should still be uploaded into your calendar to be able to access them properly. As mentioned in this documentation, you can import an iCalendar file directly into your calendar by copying and pasting it into a text document. Save the document with an ".ics" extension, then upload it into your calendar.

Additionally, based from this forum, Google Calendar still has no feature of handling events directly from .ics files. If you want this feature to be added in Google Calendar, you can submit a feature request here.

However, you may also opt to try the given workaround in this post and see if it works for you.