【发布时间】:2015-08-17 21:22:46
【问题描述】:
我正在寻找一个用于向 Windows Phone 8 日历添加事件的 cordova 插件。科尔多瓦插件注册表上没有插件。我的解决方法是编写原生插件-
public void addCalendarEvents(String str)
{
string[] calendarValues = str.Split('|');
SaveAppointmentTask saveAppointmentTask = new SaveAppointmentTask();
int appointmentYear = Int32.Parse(calendarValues[3]);
int appointmentMonth = Int32.Parse(calendarValues[4]);
int appointmentDate = Int32.Parse(calendarValues[5]);
float appointmentTime = float.Parse(calendarValues[6]);
DateTime scheduleApptDateStart = (new DateTime(appointmentYear, appointmentMonth, appointmentDate, 7, 0, 0)).AddHours(appointmentTime);
DateTime scheduleApptDateEnd = (new DateTime(appointmentYear, appointmentMonth, appointmentDate, 7, 30, 0)).AddHours(appointmentTime);
saveAppointmentTask.StartTime = scheduleApptDateStart;
saveAppointmentTask.EndTime = scheduleApptDateEnd;
saveAppointmentTask.Subject = calendarValues[1];
saveAppointmentTask.Location = calendarValues[2];
saveAppointmentTask.Details = "";
saveAppointmentTask.IsAllDayEvent = false;
saveAppointmentTask.Reminder = Reminder.FifteenMinutes;
saveAppointmentTask.AppointmentStatus = Microsoft.Phone.UserData.AppointmentStatus.Busy;
saveAppointmentTask.Show();
}
并使用它调用它
var inputCalendarString = notes + '|' + title + '|' + location + '|' + appointmentDate.getFullYear() + '|' + (appointmentDate.getMonth() + 1) + '|' + appointmentDate.getDate() + '|' + '1.0' + '|' + ' ';
cordova.exec(null, null, "AddCalendarEvents", "addCalendarEvents", inputCalendarString);
它适用于一个事件,但如果我有事件循环,它就不起作用。它不会进入科尔多瓦成功回调。如果有人写了这样的插件,那将是非常有帮助的。
【问题讨论】:
标签: javascript cordova windows-phone-8 phonegap-plugins