我正在使用cordova处理iPhone的phonegap应用。我正在尝试实现一个场景,当用户单击特定按钮添加事件时,我需要打开iPhone本机日历。我跟着this link完成了我的任务,即用于IPhone的Calendar Plugin。
我按照指定执行了以下步骤:
我的HTML文件看起来像这样:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, target-densitydpi=device-dpi" />
<title>My Calendar Plugin</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<script src="assets/Scripts/jquery-1.9.1.min.js"></script>
<script src="assets/Scripts/cordova-2.3.0.js"></script>
<script type="text/javascript" src="assets/Scripts/calendar.js"></script>
<script type="text/javascript" src="assets/Scripts/index.js"></script>
<script type="text/javascript">
function addEvent()
{
var cal = new calendarPlugin();
console.log("creating event");
var title= "My Sample Appt";
var location = "Los Angeles";
var notes = "This is a sample note";
var startDate = "2012-04-16 09:30:00";
var endDate = "2012-04-16 12:30:00";
var errCall = function(theerror) {
console.log("Error occurred - " + theerror);
}
var succCall = function(themessage) {
console.log("Success - " + themessage);
}
cal.createEvent(title,location,notes,startDate,endDate, succCall, errCall);
return false;
}
</script>
</head>
<body>
<input type="button" id="btnAddEvent" onclick="return addEvent();"/>
</body>
</html>
但我无法打开原生日历并在指定日期添加活动。我已经回顾了几个StackOverflow问题和Google网上论坛讨论,但它们并没有为我工作。我已根据github的issues部分中指定的IPhone 6更新更改了calendarPlugin.m和calendarPlugin.h文件。如果我在phonegap中实施calendarplugin的方向错误,请引导我。
答案 0 :(得分:0)
尝试
cal = window.plugins.calendarPlugin
代替,
cal = new calendarPlugin()
看看是否有帮助。