Languages

Menu
Sites
Language
Create Calendar event and assign reminder


            var ev = new tizen.CalendarEvent({
                description : 'HTML5 Introduction',
                summary : 'HTML5 Webinar ',
                startDate : new tizen.TZDate(2015, 4, 07, 18, 51),
                endDate : new tizen.TZDate(2015, 4, 10, 18, 52),
                location : 'Huesca'
            });

            myCalendar.add(ev);
            console.log('Event added with UID ' + ev.id.uid);

 

how i can put reminder and on start time with sound

Responses

15 Replies
Alex Dem

Hi,
I don't know all your deatils but regarding reminder - try to look onto alarm api: https://developer.tizen.org/documentation/articles/alarm-api-guide
It is triggered even if your app has been closed already.
Alexey.

Marco Buettner

All calender events have the property "alarm", its a DOMString[]

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.web.apireference/html/device_api/mobile/tizen/calendar.html#CalendarAlarm

var ev = new tizen.CalendarEvent({
        description : 'HTML5 Introduction',
        summary : 'HTML5 Webinar ',
        startDate : new tizen.TZDate(2015, 4, 7, 18, 51),
        endDate : new tizen.TZDate(2015, 4, 10, 18, 52),
        location : 'Huesca'
    }),
    alarm = new tizen.CalendarAlarm(new tizen.TZDate(2015, 4, 7, 18, 51), "SOUND");

ev.alarm = [alarm];

 

AVSukhov

Hello,

You can use CalendarAlarm interface with AlarmMethod enum.

appdaily

thanks ,

var myCalendar = tizen.calendar.getDefaultCalendar("EVENT");

    		var ev = new tizen.CalendarEvent({
				description : 'HTML5 Introduction',
				summary : 'HTML5 Webinar ',
				startDate : new tizen.TZDate(2015, 4, 07, 19, 09),
				endDate : new tizen.TZDate(2015, 4, 10, 19, 52),
				location : 'Huesca'
			});
			var alarm = new tizen.CalendarAlarm(new tizen.TimeDuration(0,
					"MINS"), "SOUND");
			ev.alarms = [ alarm ];
			myCalendar.add(ev);
			console.log('Event added with UID ' + ev.id.uid);

in this way i am adding event and say by this i am getting event id 640

so to delete

var myCalendar;
    		// Defines the error callback.
			function errorCallback(response) {
				console.log('The following error occurred: ' + response.name);
			}

			// Defines the event success callback.
			function eventSearchSuccessCallback(events) {
				// Deletes the first existing event.
				myCalendar.remove(events[640].id);
TypeError: 'undefined' is not an object (evaluating 'events[640].id')
				console.log('The first event was removed');
			}

			// Gets default calendar
			myCalendar = tizen.calendar.getDefaultCalendar("EVENT");

			// Finds all events in Calendar
			myCalendar.find(eventSearchSuccessCallback, errorCallback);

but it giving undefined' is not an object (evaluating 'events[640].id')

AVSukhov

Hello,

Using "find" method you get array of all events (CalendarItem) objects. But ev.id.uid return unique calendar event identifier and this uid does not match with the sequence number of event in events array from find method, ie you're trying to get an element with index are outside of the array and get undefined.

In this case you need to either use find method with event filtering based on the identifier or use "ev" references to your CalendarEvent to delete it.

F.e.

myCalendar.remove(ev.id)

Marco Buettner

I think u didnt understand the basics of javascript - its ok.

You reference (events[640]) is the 639th item of the array, so maybe it is wrong? You can check when you use

console.log(events.length);

It will return the size of the array events.

In the Tizen Calendar Database TASKS and EVENTS are mixed. I think you event response list is lower than 640 :D

The best way is you filter in the find method the event by the id, you response has in this case only ONE response and you can reference it by events[0].id.

In your case you have to iterate ALL events until you find the event with the id

function eventSearchSuccessCallback(events) {
    for(var i = 0, len = events.length; i < len; ++)
    {
        if(events[i].id === 640)
        {
            myCalendar.remove(events[i].id);
            console.log("event was removed");
        }
    }
}

 

appdaily

when i am adding

startDate : new tizen.TZDate(Syear, Smonth, Sdate, Shrs, Smin),

Smonth is 05 but its adding to 04

Marco Buettner

In JS the months goes from 0-11 (0 = January, 11 December) ... If you will use the documentation, you have found it on the TZDate object information.

appdaily

how i can mark done viva code ? i have event id

Marco Buettner

Check: https://developer.tizen.org/dev-guide/2.3.0/org.tizen.web.apireference/html/device_api/mobile/tizen/calendar.html#CalendarItemInit

complete accept integer between 0 and 100, if complete 100 the task is done

Marco Buettner

sorry, I mean "progress" not "complete" ;D

appdaily

task.progress so i have to give id ?

Marco Buettner
function markAsComplete(eventId) {
    // Defines the error callback.
    function errorCallback(response) {
        console.log( 'The following error occurred: ' +  response.name);
    }
    
    // Defines the event search success callback.
    function eventSearchSuccessCallback(events) {
        console.log(events.length + ' results found.');

        events[0].progress = 100;

        myCalendar.update(events[0]);
    }
    
    // Gets the default calendar.
    var calendar = tizen.calendar.getDefaultCalendar("EVENT");
    // Finds all events the calendar that contain in the summary the string Tizen.
    var filter = new tizen.AttributeFilter('id.uid', 'EXACTLY', eventId);

    calendar.find(eventSearchSuccessCallback, errorCallback, filter, sortingMode);
}

 

Marco Buettner

remove "sortingMode" from the find-method ;)

AVSukhov

Hello,

you can try following code:

event.status = "COMPLETE";
myCalendar.update(event);