Skip to content

API MISUSE: nil event store in initialization of EKCalendar instance for createEventInteractivelyWithOptions #564

@KaiserRuben

Description

@KaiserRuben

Description

For some reason, it seems like I don't have access to the Calendar on iOS. I added 'Privacy - Calendars Usage Description' to Info.plist, so this shouldn't be it.

Android works fine.

Version

iOS 17
Xcode 15.0 beta 3
package.json (excerpt):

{
  "dependencies": {
    "@awesome-cordova-plugins/calendar": "^6.4.0",
    "@awesome-cordova-plugins/core": "^6.4.0",
    "@capacitor/ios": "^4.8.1",
    "@ionic/core": "^7.0.0",
    "vue": "^3.2.47"
  }
}

I have the same behaviour for iOS 16 and Xcode 14 as well.

Logs

Xcode Log:

To Native Cordova ->  Calendar hasReadWritePermission Calendar1008503186 ["options": []]
To Native Cordova ->  Calendar listCalendars Calendar1008503187 ⚡️  [log] - **Has Calendar Permission: false**
["options": []]
⚡️  [log] - Calendars found: []
To Native Cordova ->  Calendar createCalendar Calendar1008503188 ⚡️  [log] - Calendar not found, creating it
["options": [{
    calendarColor = "#0D0cfb";
    calendarName = myCalendar;
}]]
⚡️  [log] - Calendar created: {"id":"71E75CCC-22BF-4386-BE9E-89924B276D40"}
XPC connection was invalidated
No match found for calendar with name: myCalendar
**API MISUSE: nil event store in initialization of EKCalendar instance**
created calendar: myCalendar

Code

I have a function called getCalendar which gets the calendar for me, and, if it does not exist yet, creates it. For testing I added Calendar.hasReadWritePermission(), which should always be true on iOS, but it is not...? This can be seen in the Xcode log.

JavaScript:

import {Calendar} from "@awesome-cordova-plugins/calendar";
export async function getCalendar(): Promise<{ id: (string | undefined) } | null> {
    if (isPlatform('android')) {
        //...
    }
    try {
        const hasPermission = await Calendar.hasReadWritePermission()
        console.log('Has Calendar Permission: ' + hasPermission)

        const calendars = await Calendar.listCalendars()
        console.log('Calendars found: ' + JSON.stringify(calendars))
        let calendar = calendars.find((c: any) => c.name === 'KultNow')

        if (!calendar) {
            console.log('Calendar not found, creating it')
            calendar = {}
            calendar.id = await Calendar.createCalendar({
                calendarName: 'myCalendar',
                calendarColor: '#0D0cfb',
            })

            console.log('Calendar created: ' + JSON.stringify(calendar));
        }
        return calendar
    } catch (e) {
        console.warn('Could not get calendars, maybe no permissions?')
        return null
    }
}
//...
await Calendar.createEventInteractivelyWithOptions(event.name, event.place, event.description, new Date(event.startDate), new Date(event.startDate), options)

Thanks for your help

I'd be thankful for any hints on what I missed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions