Tutorial: Adding events to the calendar (iOS)

Share on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0

Corona SDK currently does not have direct access to the iOS “calendar” app, but you can still use your Corona-based app to add events to it. The process basically works like this:

  1. Collect input data from the user.
  2. Save an .ics file to your local file system.
  3. Upload that file to a web server.
  4. Use system.openURL() to access the file.

Collect input data

Getting input data from the user is fairly straightforward. First, decide on the User Interface (UI) you need and then collect the data. The type of data is defined in the standard ical format:

You can learn more about the format here. Note that the key items you must provide are:

  • UID — A unique ID for the event.
  • DSTAMP — The date and time the event was created.
  • DTSTART — The date and time the event starts.
  • DTEND — The date and time the event ends.
  • SUMMARY — The title of the event.

Save the file

With the required info gathered, you must save it to the system.DocumentsDirectory with the .ics extension. If you’ve never worked with reading/writing files, please refer to this guide.

Upload the file

Once the file is saved, you must upload it to a web server. The steps to upload a file and set up an upload script is beyond the scope of this tutorial, but if you’re new to the process, please see this tutorial.

Open the URL

When you’ve successfully completed the previous steps and you have a URL for the file, simply open that URL using system.openURL(). The operating system should recognize the .ics file and realize that you’re trying to set an event (you’ll be prompted to subscribe to the calendar and add the event). For example:

Sample PHP script

Forum member @alzaabi98 has shared a PHP script which can be used in place of uploading the file. This script and the sample code can be found here.


Hopefully this tutorial has shown you how to add basic events to the iOS calendar app. While this method does not offer any “advanced” calendar features, it provides you with a fairly simple way to input user-generated or other events.

Share on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0
Rob Miracle

Rob Miracle creates mobile apps for his own enjoyment and the amusement of others. He serves the Corona Community in the forums, on the blog, and at local events.

This entry has 0 replies

Comments are closed.