builttoroam / device_calendar

A cross platform plugin for modifying calendars on the user's device
https://pub.dev/packages/device_calendar
BSD 3-Clause "New" or "Revised" License
260 stars 263 forks source link

Add EventStatus property to Event #410

Closed lucasribolli closed 2 years ago

lucasribolli commented 2 years ago

Android: https://developer.android.com/reference/android/provider/CalendarContract.EventsColumns#STATUS iOS: https://developer.apple.com/documentation/eventkit/ekevent/1507158-status

This property is useful when the organizer provides a confirmation of the meeting to the attendees. There is more information about it in this link

In iOS it seems to be read only. That's the reason I add a platform verification in example, allowing EventStatus edition only in Android. But I am not sure if there is a way to edit the status property in iOS side.

I tested it in both platforms

GoldenSoju commented 2 years ago

@lucasribolli @thomassth One question regarding the event status on Android side. After adding the EventStatus to the package, I get an error when I try to delete an instance of an event. Error: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference

It doesn't matter when I try to delete an event completely, only when I try to delete an instance. I got it solved by changing:

values.put(Events.STATUS, getEventStatus(event.eventStatus))

to

var status: Int? = getEventStatus(event.eventStatus)
if (status != null) {
   values.put(Events.STATUS, status)
}

(CalendarDelegate.kt 599)

So I guess, if we put the value Status with null, the error occurs, while not putting the Status value at all if null, it works fine.

I am wondering if someone else has experienced this behaviour?

lucasribolli commented 2 years ago

It sounds a no tested scenario and I unfortunately don't get this behavior. Maybe status is like recurrenceRule that needs to not be null to work as expected. You can make a PR fixing this as seem this property is not released yet. If you prefer, I can do it for you.

GoldenSoju commented 2 years ago

I added the fix to another pull request. (Link) It might be in connection with a different recurrence rule implementation.