2013-07-05 25 views
2

我正在爲使用科爾多瓦的iPhone使用phonegap應用程序。我試圖實現一個場景,當用戶單擊某個特定按鈕添加事件時,需要打開iPhone本機日曆。我已按照this link完成我的任務,即iPhone的日曆插件。如何在iPhone中使用科爾多瓦和phonegap應用程序集成日曆插件

我做了以下的步驟,因爲他們規定:

  1. 新增CalendarPlugin.m,CalendarPlugin.h在Plugins文件夾
  2. 新增calendar.js文件,並在我的.html文件添加refrence。
  3. 增加了依賴關係EventKit框架和EventKitUI框架
  4. 添加插件的日期插件的key /對值在 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> 

但我無法打開內置的日曆,並在指定日期添加事件。我已經回顧了幾個StackOverflow問題和Google網上論壇討論,但他們沒有爲我工作。根據github的問題部分中指定的IPhone 6更新,我更改了我的calendarPlugin.m和calendarPlugin.h文件。如果我在實現手機日曆插件方面做錯了方向,請指導我。

回答

0

嘗試

cal = window.plugins.calendarPlugin 

代替,

cal = new calendarPlugin() 

看看是否有幫助。

相關問題