• Home
  • Events
  • Appcelerator Titanium Quickie Event Update: Quickly Add an Event To IOS Calendar
 
29
0
0

Appcelerator Titanium Quickie Event Update: Quickly Add an Event To IOS Calendar

Aaron SaundersviaClearly Innovative
January 09, 2013

I released one of my first Appcelerator Modules, Quickie Event, over a year ago and it was to solve a pretty simply problem; add events to the IOS Calendar without a dialog appearing. Some I worked through the IOS Module Developers Guide and built a basic module. After I completed the basic task… I realized there was more I wanted to to

  • Add an Event to the Calendar with the dialog
  • Find Events by a specific date range
  • Add an alarm to the event
  • Add the second alarm to the event

Because I was out of time and busy doing all of the other things a small business owner has to do I let the first version of the module languish… time passed… and I did not get rich from the module… but it needed an update.

Apple has now introduced Calendar security so the module needed to prompt users for permission to access the Calendar; so off to the github repo for updates. Once I started the updates, with the help of one of Clearly Innovative’s awsome developers, I figured I might as well do the rest.

This is how you find and Event by a date range

var startDate = new Date(); 
startDate.setHours(startDate.getHours() - 48); 
var endDate = new Date(); 
endDate.setHours(endDate.getHours() + 48); 
var o = quickevent.findEvents({ start : startDate, end : endDate });

 

And then you get an array of JSON objects containing the result

"data": [
    {
        "lastModifiedDate": "Jan 8, 2013, 5:18 PM",
        "hasAlarms": "true",
        "hasRecurrenceRules": "false",
        "endDate": "Jan 8, 2013, 2:50 PM",
        "eventIdentifier": "4AAB3DDF-FAC6-4E26-AD90...",
        "location": "Times Square NYC",
        "startDate": "Jan 8, 2013, 2:45 PM",
        "creationDate": "Jan 8, 2013, 5:18 PM",
        "title": "Test Quick Event Title"
    },
    {
        "lastModifiedDate": "Jan 8, 2013, 5:15 PM",
        "hasAlarms": "true",
        "hasRecurrenceRules": "false",
        "endDate": "Jan 8, 2013, 2:50 PM",
        "eventIdentifier": "4AAB3DDF-FAC6-4E26-AD90...",
        "location": "Times Square NYC",
        "startDate": "Jan 8, 2013, 2:45 PM",
        "creationDate": "Jan 8, 2013, 5:15 PM",
        "title": "Test Quick Event Title"
    },
    {
        "lastModifiedDate": "Jan 8, 2013, 5:02 PM",
        "hasAlarms": "true",
        "hasRecurrenceRules": "false",
        "endDate": "Jan 8, 2013, 2:50 PM",
        "eventIdentifier": "4AAB3DDF-FAC6-4E26-AD90...",
        "location": "Times Square NYC",
        "startDate": "Jan 8, 2013, 2:45 PM",
        "creationDate": "Jan 8, 2013, 5:02 PM",
        "title": "Test Quick Event Title"
    },
    {
        "lastModifiedDate": "Jan 8, 2013, 5:01 PM",
        "hasAlarms": "true",
        "hasRecurrenceRules": "false",
        "endDate": "Jan 8, 2013, 2:50 PM",
        "eventIdentifier": "4AAB3DDF-FAC6-4E26-AD90...",
        "location": "Times Square NYC",
        "startDate": "Jan 8, 2013, 2:45 PM",
        "creationDate": "Jan 8, 2013, 5:01 PM",
        "title": "Test Quick Event Title"
    }
]

 

You can get a specific event by it’s identitifier

var o = quickevent.getEventByIdentifier("4AAB3DDF-FAC6-4E26-AD90...");
Ti.API.info("getEventByIdentifier: " + JSON.stringify(o, null, 2));

 

And here is the complete parameter list for doing other good stuff

    var quickeventMgr = require('clearlyinnovative.quickevent');
    var quickevent = quickeventMgr.create();

    // set the event listeners for the callbacks
    quickevent.addEventListener('cancel', function(e) {
        Ti.API.info("cancel");
    });

    quickevent.addEventListener('success', function(e) {
        Ti.API.info('success ');
    });

    // create the event
    quickevent.addEvent({
        "dateFormat" : "yyyy/MM/dd hh:mm a", // default format is MMM dd yyyy HH:mm
        "startDate" : "2013/01/08 2:45 pm",
        "endDate" : "2013/01/08 2:50 pm",
        //"timeZone" : "EST", // can be specified or used system default
        "location" : "Times Square NYC",
        "title" : "Test Quick Event Title",
        "noUI" : "true", // add this parameter to use module with no UI
        "allDay" : "false", // sets the event to all day
        "dump" : "false", // dumps debug output of the event
        "alarmInSecs" : "-60.0", // set alarm for the event in seconds
        "alarmInSecs2" : "-30.0" // set second alarm for the event in seconds
    });

 

The new version of the module should be updated in the Appcelerator Marketplace later this week.

Discussion

-