Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Display an alert 15 minutes a calendar Event

$
0
0

Hi, I use this code to set an Event (and create an Alert) on an iOS Calendar:

btn.addEventListener("click", function(e) {
 
            if (Ti.Calendar.eventsAuthorization == Ti.Calendar.AUTHORIZATION_AUTHORIZED) {
 
              var defaultCalendar = Ti.Calendar.defaultCalendar;
 
              var startDate = new Date(new Date().getTime()),
                  endDate = new Date(new Date().getTime() + 4 * 60000);
 
              var myEvent = defCalendar.createEvent({
                title : 'MyEvent',
                notes : 'Just a test Event',
                location : 'Anywhere',
                begin : startDate,
                end : endDate,
                availability : Ti.Calendar.AVAILABILITY_FREE,
                allDay : false,
              });
 
              var eventAlert = myEvent.createAlert({
                absoluteDate : new Date(new Date().getTime() - (1000 * 60 * 2))
              });
 
              var allAlerts = new Array(eventAlert);
 
              myEvent.save(Ti.Calendar.SPAN_THISEVENT);
 
            });
In this little test, my intention was the following: I wanted to show the user an alert 2 minutes before the end of the event. This didn't work (it sets the event in the calendar but there's no alert: I must manually edit the event to add it...)

Aside from this little test, my goal is a little different: display an alert 15 minutes before an event begins.

What am I doing wrong? Can you help me?


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>