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
270 stars 271 forks source link

PlatformException(500, Attendees cannot be changed., null) #249

Open jayeshpansheriya opened 4 years ago

jayeshpansheriya commented 4 years ago

in android simulator app is working fine, but when i test it in ios simulator without attendees is working fine but when i add attendees it showen exception,

[599] Device calendar plugin ran into an issue. Platform specific exception [500], with message :Attendees cannot be changed., has been thrown.

Simulator Screen Shot - iPhone 11 Pro Max - 2020-06-24 at 11 36 22

nickrandolph commented 4 years ago

Is this with an event that was created through the plugin? What account type is it (office365, Gmail etc) and what device type (iOS or Android)?

jayeshpansheriya commented 4 years ago

Is this with an event that was created through the plugin? => yes i have used plugin device_calendar: ^3.1.0

its iphone inbuild calendar. List of calendar screen i selected Calendar named and i have also checked is not read only

jayeshpansheriya commented 4 years ago

i have also try to make demo app from your github example, same issues face in ios device. i am used selected ios calendar from list of calendar screen, with out add attendees is working fine.

jayeshpansheriya commented 4 years ago

i have again try to copy example from https://github.com/builttoroam/device_calendar/tree/develop/example. but face same issues

Simulator Screen Shot - iPhone 11 Pro Max - 2020-07-08 at 17 31 43

[599] Device calendar plugin ran into an issue. Platform specific exception [500], with message :Attendees cannot be changed., has been thrown.

andzejsw commented 3 years ago

@jayeshpansheriya Does everything work fine with 4.x version!?

ConanShin commented 3 years ago

@andzejsw nop still an opened issue. I'm facing same error.

thomassth commented 3 years ago

I think I saw it too, but since I could add events just fine I didn't think it was important.

Is there any notable problem when handling attendees on iOS? Or is the only issue the warning in console (ie not urgent to fix)?

scorpionate commented 3 years ago

I think it's because EkParticipant: EventKit cannot add participants to an event nor change participant information. Use the properties in this class to get information about a participant.

While the Event's creation it seems to be unharmful, during the Event editing it just can't play with attendees. In the SwitfDeviceCalendarPlung.swift there is code that tries to manipulate attendees:

 private func setAttendees(_ arguments: [String : AnyObject], _ ekEvent: EKEvent?) {
        let attendeesArguments = arguments[attendeesArgument] as? [Dictionary<String, AnyObject>]

        if attendeesArguments == nil {
            return
        }

        var attendees = [EKParticipant]()
        for attendeeArguments in attendeesArguments! {
            let name = attendeeArguments[nameArgument] as! String
            let emailAddress = attendeeArguments[emailAddressArgument] as! String
            let role = attendeeArguments[roleArgument] as! Int
            let attendanceStatus = attendeeArguments[attendanceStatusArgument] as! Int

            if (ekEvent!.attendees != nil) {
                let existingAttendee = ekEvent!.attendees!.first { element in
                    return element.emailAddress == emailAddress
                }
                if existingAttendee != nil && ekEvent!.organizer?.emailAddress != existingAttendee?.emailAddress{
                    attendees.append(existingAttendee!)
                    continue
                }
            }

            let attendee = createParticipant(
                name: name,
                emailAddress: emailAddress,
                role: role)

            if (attendee == nil) {
                continue
            }

            attendees.append(attendee!)
        }

        ekEvent!.setValue(attendees, forKey: "attendees")
    }
fauzi2107 commented 2 years ago

Halo, I'm facing same issue with device_calendar: ^4.2.0 on iOS device version 15,4, is any update to this issue?

thomassth commented 2 years ago

We should have new ways to handle attendants properly now

And the demo has included the new iOS specific popup for attendants

SuperKrallan commented 1 year ago

Still facing the same problem. Running on device_calendar 4.2.0.

SuperKrallan commented 1 year ago

Dug into this a bit and found a possible workaround here: https://stackoverflow.com/questions/30627694/modifying-ekparticipants-attendees-in-eventkit-like-sunrise ...which is the trick MaksMaxx is mentioning above, but this "trick" seems already to be done in setAttendees metod of the SwiftDeviceCalendarPlugin.swift, but it still does not fly. But found another clue in the small printed comments of the above link: "Don't try it in simulator .it's not working in simulator .... it worked for me in device ." ...and that was true in my case as well. I get the error in the simulator, but not when I run it on my device. So for me it is "problem solved".

akshaydoshi2 commented 1 year ago

I am facing a similar issue. I'm not updating the attendees. But I am trying to update an event that I have created using the plugin. The functionality works as expected on iOS but returns the following error on Android device. The android device I am using is OnePlus Nord 2.

PlatformException(500, Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference, null, null) Device calendar plugin ran into an issue. Platform specific exception [500], with message :"Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference", has been thrown.

Following is my json of event data: {calendarId: 1, eventId: 833, eventTitle: Appointment, eventDescription: , eventStartDate: 1678027560000, eventStartTimeZone: Asia/Kolkata, eventEndDate: 1678031160000, eventEndTimeZone: Asia/Kolkata, eventAllDay: false, eventLocation: Eiffel Tower, eventURL: null, availability: BUSY, eventStatus: null, reminders: [{minutes: 60}]}

FelixYew commented 1 year ago

I have the same issue by replacing the code below in CalendarDelegate.kt fixed the problem.

private fun getEventStatus(eventStatus: EventStatus?): Int? = when (eventStatus) { EventStatus.CONFIRMED -> Events.STATUS_CONFIRMED EventStatus.TENTATIVE -> Events.STATUS_TENTATIVE EventStatus.CANCELED -> Events.STATUS_CANCELED else -> 0 }

thomassth commented 1 year ago

Submit a PR and I'll merge it :)

bjsapkota1313 commented 8 months ago

@thomassth Is this issue has been resolved or not yet? I was trying in the Ios 17 emulator and I faced the same issue.

nikita2022121 commented 2 months ago

I also had the same issue. I solved it by adding eventStatus value when updating the event. If eventStatus is something other than these values: EventStatus.CONFIRMED , EventStatus.TENTATIVE ,EventStatus.CANCELED it is not working because the getEventStatus is not returning value in else as @FelixYew has mentioned above about replacing it.