您好我正在为iOS和Android 开发 phonegap应用程序。
我需要整合Calendar API才能从iOS和Android 访问日历。
我尝试过一些插件但它没有达到我的要求。
我需要在本机日历中添加事件,编辑/修改事件和删除事件。
请指导我。
提前致谢。
答案 0 :(得分:1)
试试这个希望它会对你有帮助。
var strCalender = { "summary": strEventName,"eventDesc": strCategoryName,"begin": new Date(y, m, d),"beginYear": y,"beginMonth": m,"beginDate": d,"endYear": y,"endMonth": m,"endDate": d,"end": new Date(y, m, d), "eventtype": "1", "categoury": strCategoryName, "venue": strVenue, "color": "blue", "eventtime": strTime, "eventDate": strDate, "eventdetails": strClickStrings }
calendarInNativeApp(strCalender);
function calendarInNativeApp(eventscalendar){
var eventHours=eventscalendar.eventtime;
eventHours=eventHours.split(":")[0];
var eventMins=eventscalendar.eventtime;
eventMins=eventMins.split(":")[1];
var eventsInfo = eventscalendar;
var startDate = new Date(eventsInfo.beginYear,eventsInfo.beginMonth,eventsInfo.beginDate,eventHours,eventMins,0,0,0); // beware: month 0 = january, 11 = december
var endDate = new Date(eventsInfo.endYear,eventsInfo.endMonth,eventsInfo.endDate,23,59,0,0,0);
var deleteStartDate = new Date(2015,5,10,18,30,0,0,0); // beware: month 0 = january, 11 = december
var deleteEndDate = new Date(2015,5,10,19,30,0,0,0);
var deleteTitle="Event4";
var title = eventsInfo.summary;
var eventLocation = eventsInfo.venue;
var notes = eventsInfo.eventDesc;
var success = function(message) {JSON.stringify(message); };
var error = function(message) { message; };
if(device.platform == "iOS"){
var createCalOptions = window.plugins.calendar.getCreateCalendarOptions();
createCalOptions.calendarName = "Calendar";
createCalOptions.calendarColor = "#FF0000"; // an optional hex color (with the # char), default is null, so the OS picks a color
createCalOptions.firstReminderMinutes = 120; // default is 60, pass in null for no reminder (alarm)
createCalOptions.secondReminderMinutes = 5;
window.plugins.calendar.createCalendar(createCalOptions,success,error);
window.plugins.calendar.createEventInNamedCalendar(title,eventLocation,notes,startDate,endDate,"Calendar",success,error);
}
else if(device.platform == "Android"){
var calOptions = window.plugins.calendar.getCalendarOptions(); // grab the defaults
calOptions.firstReminderMinutes = 120; // default is 60, pass in null for no reminder (alarm)
window.plugins.calendar.createEventWithOptions(title,eventLocation,notes,startDate,endDate,calOptions,success,error);
}
}