我目前正在使用Cordova(Phonegap),Backbone和JQtouch开发webapp.除此之外,我需要在用户日历中添加事件.
在Android上一切正常.我还在使用Cordova 2.0.0.(我没有升级到最新版本).滚动工作,导航正常,我可以在我的日历中添加事件!
在iPhone上,它是不同的.由于我希望我的应用程序在iOS 6上运行,因此我在Mac上安装了Cordova 2.2.0.从那以后,我再也无法在日历中添加事件了.它使用cordova 2.0.0(在iphone上),但现在不行.
经过调查,我发现cordova.exec()未定义.
我搜索了很多关于这个问题的内容,但似乎没有人,除了我,现在遇到了这个问题.
以下是使用Cordova 2.0.0但不支持Cordova 2.2.0的代码示例:
calendar.js,Cordova的日历插件.我没有写.在Android上我得到消息"cordova.exec已定义",而在iOS上我得到了另一个.
// Cordova Calendar Plugin
// Author: Felix Montanez
// Created: 01-17-2012
// Contributors:
// Michael Brooks
function calendarPlugin()
{
}
calendarPlugin.prototype.createEvent = function(title,location,notes,startDate,endDate)
{
if('function' == typeof(cordova.exec)) {
alert("cordova.exec is defined");
} else {
alert("cordova.exec is not defined");
}
cordova.exec(null,null,"calendarPlugin","createEvent", [title,location,notes,startDate,endDate]);
};
calendarPlugin.install = function()
{
if(!window.plugins)
{
window.plugins = {};
}
window.plugins.calendarPlugin = new calendarPlugin();
return window.plugins.calendarPlugin;
};
cordova.addConstructor(calendarPlugin.install);
Run Code Online (Sandbox Code Playgroud)
调用函数createEvent的代码(它正在工作,因为我得到了上一个警报)
if (confirm('Do you want …Run Code Online (Sandbox Code Playgroud)