如何按标题从离子设备日历中删除事件?

How to delete event from device calendar in ionic by title?

我正在研究离子应用。我想使用 event title 从设备日历中删除事件?我知道使用 window.plugins.calendar.deleteEvent() 方法,但是

  1. 我可以用它只按标题删除事件吗?
  2. 有没有什么方法可以删除日历中的所有事件 有特定的标题?
  3. 覆盖设备日历上一个事件的最佳方法是什么。

以下是我的代码

        var createEventSuccess = function () {
          alert('Job added to calendar:'+job.id);
        }
        var createEventError = function (error) {
          alert('Error adding Job to calendar : ' + error);
        }

        var deleteEventSuccess = function () {
            alert('Event Deleted:'+job.id);
            window.plugins.calendar.createEventWithOptions(title, location, job.services, scheduledTime, scheduledTime, calOptions, createEventSuccess, createEventError);
        }

        var deleteEventError = function (error) {
            alert('Problem in Deleting:'+error);
        }

        var findEventSuccess = function () {
            alert('Event found');
            window.plugins.calendar.deleteEvent(title, null, null, null, null, deleteEventSuccess, deleteEventError);
        }

        var findEventError = function (error) {
            alert('Event not found : ' + error);
            window.plugins.calendar.createEventWithOptions(title, location, job.services, scheduledTime, scheduledTime, calOptions, createEventSuccess, createEventError);
        }

        window.plugins.calendar.findEvent(title, null, null, null, null, findEventSuccess, findEventError)

我不想依赖其他字段,因为字段可能会因标题而改变,所以我只想使用标题查找或删除职位。

我在 google 上搜索过,但没有找到与我的要求相关的文件。

请帮忙..

谢谢。

plugin's Site 上面写着:

  // delete an event (you can pass nulls for irrelevant parameters, note that on Android `notes` is ignored). The dates are mandatory and represent a date range to delete events in.
  // note that on iOS there is a bug where the timespan must not be larger than 4 years, see issue 102 for details.. call this method multiple times if need be
  // since 4.3.0 you can match events starting with a prefix title, so if your event title is 'My app - cool event' then 'My app -' will match.
  window.plugins.calendar.deleteEvent(newTitle,eventLocation,notes,startDate,endDate,success,error);

日期是强制性的,表示要删除事件的日期范围。