EddyVerbruggen / Calendar-PhoneGap-Plugin

:date: Cordova plugin to Create, Change, Delete and Find Events in the native Calendar
773 stars 402 forks source link

Recurring event issues on android devices #532

Open DSz4 opened 4 years ago

DSz4 commented 4 years ago

I encountered some issues on different android devices and using different calendars when creating recurring events in an ionic app.

Steps:

import { Calendar } from '@ionic-native/calendar';
...
constructor(private calendar: Calendar, ...) {
}

...
// create a recurring event
await this.calendar.createEventWithOptions(
    "Title example", 
    undefined, 
    "Note example", 
    new Date(2020,6,1,18,30,0,0,0),
    new Date(2020,6,1,18,45,0,0,0),
    {
        calendarId: "1",
        firstReminderMinutes: null,
        recurrence: "daily",
        recurrenceInterval: 1
    }
)

// create a second recurring event
await this.calendar.createEventWithOptions(
    "Title example 2", 
    undefined, 
    "Note example 2", 
    new Date(2020,6,2,15,30,0,0,0),
    new Date(2020,6,2,15,45,0,0,0),
    {
        calendarId: "1",
        firstReminderMinutes: null,
        recurrence: "daily",
        recurrenceInterval: 1
    }
)

// delete one of the recurring events
await this.calendar.deleteEvent(
    "Title example",  
    undefined, 
    "Note example", 
    new Date(2020,6,1,18,30,0,0,0),
    new Date(2020,6,1,18,45,0,0,0)
)

Error:

I let the user pick out a target calendar where the events will be saved. If the user picks the calendar associated with the gmail account, it works as expected.

If the user picks the "phone calendar/device calendar/my calendar" (which is provided by many devices per default), the recurring entry that I don't even edit is cut off after a seemingly random number of days in the native calendar after I delete the other event. When I examine the event in the native calendar, it still says it runs forever (or until an end date if set), but it won't be displayed after a random day (usually around 1-3 weeks after the start is the last occurrence). The same happens when using deleteEventById. Non-recurring events work fine in both calendar types and iOS works fine too.

Here's the overview of devices and calendar types, where I tested if deleting recurring events work (yes if it works, no if the error above occurs). As described above, the gmail account is the calendar associated with a gmail address and phone calendar is a calendar provided by the device by default.

Device Android Version Gmail Account Phone Calendar
Huawei P20 lite 9 yes no
Huawei Y6 9 yes no
Samsung Galaxy S8 8.0.0 no no
Nexus 5X 8.1 yes doesn't exist
Pixel XL 10 yes doesn't exist
Samsung Galaxy J5 5.1.1 yes no

I am using version 5.1.5 of the plugin and 4.14.0 of @ionic-native/calendar. The output running ionic info is:

Ionic:
   ionic (Ionic CLI)  : 4.8.0
   Ionic Framework    : ionic-angular 3.9.5
   @ionic/app-scripts : 3.2.4
Cordova:
   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 8.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 1.2.1, (and 33 other plugins)
System:
   Android SDK Tools : 26.1.1
   NodeJS            : v10.16.0
   npm               : 6.9.0
   OS                : macOS Catalina
DSz4 commented 4 years ago

Addition: I saw some issues here with storing events in non-primary calendars. However, I did not find a rule for identifying the calendar, where everything works. The Huawei Y6 has zero primary calendars, the Huawei P20 lite has the gmail account as primary calendar, while Samsung Galaxy S8 had both the gmail account and the phone calendar as primary calendars marked.