Not able to create calendar event in device calendar - Ionic 2


#1

Hi , I am trying to create calendar event from my app. Right now trying some simple code. On button click it should add an event to device calendar. Receiving no error but at same time events are not created either. Below is my .ts code:

export class HomePage {
title = "Space Race";
eventLocation = "The Moon";
notes = "Bring Sandwiches";
startDate = new Date(2017,3,25,18,30);
endDate = new Date(2017,3,25,19,30);

constructor(public nav: NavController, public calendar: Calendar) { }

createEvent(){
  this.calendar.createCalendar('MyCalendar').then(
   (msg) => { console.log(msg); },
   (err) => { console.log(err); }
 );

 this.calendar.createEvent(this.title, this.eventLocation, this.notes, this.startDate, this.endDate)
        .then(() => {
console.log("Success");
},
()=>{
console.log("Fail");
})
}

 }

#2

(I changed your post to format your code or error message correctly. Please use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.)

What is [quote=“jbhatt091, post:1, topic:87366”]
this.calendar
[/quote]
?