使用PhoneGap / jQuery Mobile以编程方式在iPhone / Android日历中添加事件? [英] Programmatically add event in iPhone/Android Calendar with PhoneGap/jQuery Mobile?

查看:112
本文介绍了使用PhoneGap / jQuery Mobile以编程方式在iPhone / Android日历中添加事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从iOS / Android中的JavaScript / jQuery Mobile / PhoneGap应用程序创建日历事件?

How can I create a calendar event from a JavaScript / jQuery Mobile / PhoneGap app in iOS/Android?

是否有任何例如PhoneGap插件?在官方存储库中没有看到任何内容。

Are there any, e.g., PhoneGap plugins? Didn't see any in the official repository.


  • 对于iOS,Event Kit框架(iOS 4.0+)似乎能够< a href =https://stackoverflow.com/questions/246249/programmatically-add-custom-event-in-the-iphone-calendar>添加活动。

  • For iOS, the Event Kit framework (iOS 4.0+) seems to be able to add an event.

推荐答案

我意识到这是一个老问题,但有一个插件。它有它的缺点,但有效。在撰写本文时,它支持以下功能:

I realize it's old question but there is plugin for this now. It has its cons, but works. At the moment of writing it supports the following functionality:


  • iOS支持:创建(静默),更新(静默)和删除(静默)事件

  • Android> = 4:创建(交互式和静默),更新(不支持),删除(静默)事件

  • Android< 4:创建(交互式),更新(不支持),删除(不支持)事件

下面是代码示例:

  var startDate = new Date(2014,2,15,18,30,0,0,0);
  var endDate = new Date(2014,2,15,19,30,0,0,0);
  var title = "My nice event";
  var newTitle = "My new nice event";
  var location = "Home";
  var notes = "Some notes about this event.";
  var success = function(message) { 
     alert("Success: " + JSON.stringify(message)); 
  };
  var error = function(message) { 
     alert("Error: " + message); 
  };

  window.plugins.calendar.createEvent(title,location,notes,startDate,endDate,success,error);

  window.plugins.calendar.modifyEvent(title,location,notes,startDate,endDate,newTitle,location,notes,startDate,endDate,success,error);

  window.plugins.calendar.deleteEvent(newTitle,location,notes,startDate,endDate,success,error);

这篇关于使用PhoneGap / jQuery Mobile以编程方式在iPhone / Android日历中添加事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆