使用 PhoneGap/jQuery Mobile 以编程方式在 iPhone/Android 日历中添加事件?

发布于 2024-12-08 18:44:38 字数 299 浏览 1 评论 0原文

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

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

  • 对于 iOS,Event Kit 框架 (iOS 4.0+) 似乎能够 添加事件

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

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

So要识趣 2024-12-15 18:44:38

根据下面的评论,现在可以为 iOS 创建 iCal 文件,为 Android 创建 vcs 文件。它将需要浏览器/设备嗅探,或者给用户选择,但它至少应该是可能的。

Per the comments below, it is now possible to create an iCal file for iOS and a vcs file for Android. It will require browser/device sniffing, or give the user the choice, but it should at least be possible.

橙味迷妹 2024-12-15 18:44:38

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

  • 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);

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 supports: create (silently), update (silently) and delete (silently) event
  • Android >= 4: create (interactively and silently), update (not supported), delete (silently) event
  • Android < 4: create (interactively), update (not supported), delete (not supported) event

Here follows code example:

  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);
独闯女儿国 2024-12-15 18:44:38

目前,PhoneGap 开发路线图不包括日历支持。然而,有很多要求。请参阅这篇名为“遵循 W3C 日历 API 的日历插件”的帖子,其中指向 PhoneGap-Calendar-Plugin 项目,其中包括对 Android 的一些初始日历支持。

Currently the PhoneGap development roadmap does not include calendar support. However, there are many requests for it. See this post called "Calendar plugin following W3C calendar API" which points to the PhoneGap-Calendar-Plugin project which includes some initial calendar support for Android.

非要怀念 2024-12-15 18:44:38

使用最新的 API,将事件添加到 iOS 日历非常简单。
但是,您需要创建自己的插件才能执行此操作。

由于这是特定于平台的,因此在官方 PhoneGap 插件出现之前,时间将会过去。

Adding an event to the iOS calendar is very simple with the latest API.
However, you need to create your own plugin in order to do it.

since this is platform specific, come time will pass before there is an official PhoneGap plugin.

夜未央樱花落 2024-12-15 18:44:38

我找到了适用于 Android 和 iOS 的插件,但它们没有相同的 JavaScript API,因此您必须为两个系统编写不同的代码或添加另一层。此外,它们也不是最新的,需要修复才能与 Cordova 2.2.0 一起运行。更糟糕的是,文档有点短:

Android

D Cheng 的 Android 插件 能够创建,删除并搜索日历事件,但已完全过时,并且无法按原样工作。 Android 4.0 中的 日历提供程序 可以让事情变得更简单但还是没有找到好的插件。 jbajor 只能添加事件,twistandshout 仅搜索事件。

iOS

Felixactv8 的 iOS 插件 能够创建、删除和搜索日历事件。请注意,在 iOS 中没有事件 ID,因此搜索事件会很有趣。 作者介绍了如何添加两者xcode 中需要的框架:

iPhone 日历使用 2 个框架,EventKit.framework 和
EventKitUI.framework。

如果单击 xcode 图标,您应该会看到项目图标并且
目标图标。单击目标图标,然后单击构建阶段。
单击“将二进制文件与库链接”的下拉列表。单击加号
窗口底部的标志,然后搜索这两个框架。添加
这两个框架,重建项目并运行它。

I found plugins for Android and iOS but they do not have the same JavaScript API so you have to write different code for both systems or add another layer. Also they are not up to date and will need fixes to run with Cordova 2.2.0. To make things worse documentation is kind of short:

Android

Dcheng's Android Plugin is able to create, remove and search calender events but is totally outdated and will not work as it is. With Android 4.0 there is a Calendar Provider that makes things easier but still I did not find a good plugin. jbajor can only add events and twistandshout only search events.

iOS

Felixactv8's iOS Plugin is able to create, remove and search calender events. Notice that in iOS there is no event id, so searching your events will be fun. The author explains how to add the two needed frameworks in xcode:

the iphone calendar uses the 2 frameworks, EventKit.framework and
EventKitUI.framework.

if you click on the xcode icon, you should see the project icon and
the target icon. click on the target icon, then click build phases.
Click the dropdown for "Link Binary with libraries. Click the plus
sign at the bottom of the window, then search for both frameworks. Add
both of those frameworks, rebuild the project and run it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文