如何使用cordova和phonegap应用程序在IPhone中集成日历插件

如何使用cordova和phonegap应用程序在IPhone中集成日历插件,iphone,cordova,Iphone,Cordova,我正在使用cordova为IPhone开发phonegap应用程序。我正在尝试实现一个场景,当用户单击特定按钮添加事件时,我需要打开IPhone本机日历。我已经完成了我的任务,即IPhone日历插件 我按照他们的说明执行了以下步骤: 在插件文件夹中添加了CalendarPlugin.m和CalendarPlugin.h 添加了calendar.js文件并在my.html文件中添加引用 添加了依赖项EventKit框架和EventKitUI框架 在中添加了具有calendarPlugin键/对值的

我正在使用cordova为IPhone开发phonegap应用程序。我正在尝试实现一个场景,当用户单击特定按钮添加事件时,我需要打开IPhone本机日历。我已经完成了我的任务,即IPhone日历插件

我按照他们的说明执行了以下步骤:

  • 在插件文件夹中添加了CalendarPlugin.m和CalendarPlugin.h
  • 添加了calendar.js文件并在my.html文件中添加引用
  • 添加了依赖项EventKit框架和EventKitUI框架
  • 在中添加了具有calendarPlugin键/对值的插件 cordova.plist文件
  • 我的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>
    
    
    我的日历插件
    函数addEvent()
    {
    var cal=新日历插件();
    console.log(“创建事件”);
    var title=“我的示例应用程序”;
    var location=“洛杉矶”;
    var notes=“这是一个示例注释”;
    var startDate=“2012-04-16 09:30:00”;
    var endDate=“2012-04-16 12:30:00”;
    var errCall=函数(错误){
    日志(“发生错误-”+错误);
    }
    var succall=函数(消息){
    log(“Success-”+themessage);
    }
    cal.createEvent(标题、位置、注释、开始日期、结束日期、成功调用、错误调用);
    返回false;
    }
    
    但我无法打开本机日历并在指定日期添加事件。我已经回顾了几个StackOverflow问题和Google小组的讨论,但它们对我来说并不奏效。根据github的问题部分指定的IPhone 6更新,我已经更改了calendarPlugin.m和calendarPlugin.h文件。如果我在phonegap中实现calendarplugin时走错了方向,请指导我。

    试试看

    cal = window.plugins.calendarPlugin
    
    而不是

    cal = new calendarPlugin()
    
    看看这是否有帮助