Sync events using iCalendar format with Google Calendar / MS Outlook / Apple devices without using APIs.

We can create a calendar file in iCalendar format and this file can be used by compatible applications like Google Calendar, MS Outlook and Apple devices for synchronizing the events automatically.
The process is simple. We need to create the calendar file (with extension .ics) in a publicly accessible URL and add the URL to the applications. The applications will check the URL at preset intervals and update the events as per the .ics file. Google Calendar have their own interval settings, so the event synchronization may be a bit delayed.

Steps to create an iCalendar
  1. First, you have to create a file with the extension .ics. This can usually be done by opening a notepad and saving with the filename calendar.ics.
  2. Now, we need to create the event entry. The basic format of the .ics file is as below:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:
//Obidos Technologies//NONSGML My Calendar//EN (IDENTIFIER FOR THE PRODUCT THAT CREATED THE CALENDAR.)
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME: OBIDOS TECHNOLOGIES Demo Calendar(NAME OF THE CALENDAR AS YOU LIKE TO SEE IN THE APPLICATION)


Event #1
BEGIN:VEVENT
DTSTART:20130527T111111Z(Date : YYYYMMDD, T is to denote time, HHMMSS
, Z denotes time is GMT)
DTEND:20130527T123456Z(Date : YYYYMMDD, T is to denote time, HHMMSS
, Z denotes time is GMT)
SUMMARY:My Test Event 1(Name of the event)
LOCATION:Cherthala,Kerala (Location of the event)
DESCRIPTION:My Test Event 1 for iCalendar. Date and Time is set as 27-May-2013, 11:11:11 GMT to 27-May-2013, 12:34:56 GMT (Description of the event)
END:VEVENT

Event #1 END

Event #2
BEGIN:VEVENT
DTSTART:20130530T100000Z

DTEND:20130530T103000Z
SUMMARY:My Test Event 2 in GMT
LOCATION:Ernakulam,Kerala
DESCRIPTION:My Test Event 2, Date and Time is set in GMT as 30-May-2013, 10:00:00 GMT to 30-May-2013, 10:30:00 GMT or 30-May-2013, 15:00:00 IST to 30-May-2013, 15:30:00 IST
END:VEVENT

Event #2 END

END:VCALENDAR



Points to Note:
  1. The content information consists of CRLF-separated content lines.
  2. Time should be specified in GMT. Your Calendar application will automatically show the exact time as per its own settings.
  3. PRODID and VERSION are  Mandatory
  4. The BOLD and Italicized text in the above demo are information and should not be included in the actual .ics file.
Once you have created the file, you can upload the file to a server and provide the link to your calendar applications.

You can try the url (webcal://www.prasanthkumars.com/calendar.ics) with your Calendar applications and see how this works.
To add the above calendar to your Google Calender, just open the above link with Google Chrome. It will suggest you to add the link to your calendar.

You can similarly create the .ics file programmatically and synchronize events with your Calendar applications.

Ref: Internet Calendaring and Scheduling Core Object Specification (iCalendar)


Comments

Popular posts from this blog

Hide notification content in Android lock screen for Messages, email, whatsapp and selected apps.

Array functions in JavaScript