EddyVerbruggen / Calendar-PhoneGap-Plugin

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

Android 4.4 (Cyanogen Mod) createEvent issue #88

Open weshardee opened 10 years ago

weshardee commented 10 years ago

On a Galaxy S3 running Android 4.4 (Cyanogen Mod), using createEvent or createEventWithOptions fires the success callback but no event is added to my calendar. Using createEventInteractively seems to work perfectly.

kvilt commented 10 years ago

Hi i am running Android 4.4 (Cyanogen Mod) on my Oneplus One and same issue.

premiumFrye commented 10 years ago

I'm experiencing the same behavior (createEvent, and createEventWithOptions not adding an event, but interactive works) on a Nexus 7 running 4.4.2. Don't know if it's a similar, but wanted to add my observation to the pile.

EddyVerbruggen commented 10 years ago

Please share your JS code with me so I can reproduce it. I have no trouble with various of my own Android devices.

Redeadly commented 9 years ago

Hi, I write the problem I've found here, because I think is related. I'm running a stock 4.3 on Samsung Nexus, I add an event with the following code: var startDate = new Date(2015,0,21,18,30,0,0,0); // beware: month 0 = january, 11 = december var endDate = new Date(2015,0,21,19,90,0,0,0); var title = "My nice event"; var location = "Home"; var notes = "Some notes about this event."; var success = function(message) { alert("Success: " + JSON.stringify(message)); console.log(message); }; var error = function(message) { alert("Error: " + message); }; window.plugins.calendar.createEvent(title,location,notes,startDate,endDate,success,error); When I run this code, the event is added correctly, but disappears after a few seconds. I discover (using window.plugins.calendar.listCalendars(success,error); ) that the calendar with id = 1 is the holiday one, so createEvent try to add the event and then, after few seconds (after sync), google delete it. From the log of my device: E/EventHandler(24718): com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden E/EventHandler(24718): { E/EventHandler(24718): "errors": [ E/EventHandler(24718): { E/EventHandler(24718): "reason": "forbidden", E/EventHandler(24718): "domain": "global", E/EventHandler(24718): "message": "Forbidden" E/EventHandler(24718): } E/EventHandler(24718): ], E/EventHandler(24718): "message": "Forbidden", E/EventHandler(24718): "

centimitr commented 9 years ago

On a MX2 running 4.4.4, createEvent doesn't add anything when called, on a MX4 running 4.4.2 it works fine.

sixkilleraz commented 9 years ago

I'm experiencing the issue with createEvent, vs createEventWithOptions not adding an event in the emulator using a 4.4.2 device (api 19). The interactive method works though. Same thing for my physical device, which is 5.0 on a Moto X (verizon). I took the code verbatim from the example in the readme

EddyVerbruggen commented 9 years ago

@Centimitr and @sixkilleraz do you recognize the symptoms of @Redeadly?

Also, @sixkilleraz can you please paste the exact code you're using? Thx!

sixkilleraz commented 9 years ago

Here's the code. The event object is valid, since I'm able to use the method createEventInteractively successfully. I will try to get a device log today for you. Thanks!

  function addToDevice() {
    var deferred = $q.defer();

    var startDate = $scope.event.time;
    var endDate = new Date(startDate);
    endDate.setMinutes(endDate.getMinutes() + 30);
    var title = $scope.event.title;
    var eventLocation = $scope.event.location;
    var notes = $scope.event.notes;
    var success = function(message) {
      deferred.resolve(message);
    };
    var error = function(message) {
      deferred.reject(message);
    };
    window.plugins.calendar.createEvent(
      title,
      eventLocation,
      notes,
      startDate,
      endDate,
      success,
      error);

    return deferred.promise;
  }
sixkilleraz commented 9 years ago

My logs are not showing the issue @Redeadly encountered.

I do have several different calendars, starting at id 14. The first one in the list is a calendar I can write to, though.

Here's all I can see in the logs. Probably not much help:

D/Calendar(28297): Added to ContentResolver

W/PluginManager(28297): THREAD WARNING: exec() call to Calendar.createEventWithOptions blocked the main thread for 71ms. Plugin should use CordovaInterface.getThreadPool().

W/BindingManager(28297): Cannot call determinedVisibility() - never saw a connection for the pid: 28297

D/SoftKeyboardDetect(28297): Ignore this event

I/CalendarProvider2(28702): Sending notification intent: Intent { act=android.intent.action.PROVIDER_CHANGED dat=content://com.android.calendar }

W/ContentResolver(28702): Failed to get type for: content://com.android.calendar (Unknown URL content://com.android.calendar)
cjjyao commented 9 years ago

Same issue for Android 4.4 on my Oneplus One - createEventWithOptions and findEvent blocked the main thread for 27ms. Plugin should use CordovaInterface.getThreadPool(). Is there a fix for this? Please let me know.

cjjyao commented 9 years ago

I just found out what the cause of this problem on my Oneplus One - I had successful callback with createEventWithOptions, but the event's not added. The problem was that there were multiple accounts in the calendar. Make sure the calendar your app is writing to is the same one you're viewing, or else it'll seem like the events weren't added. Using createEventInteractively allows you to select which account the event is added.

raphaeltm commented 9 years ago

I'm having the same problem, but it's happening with createEventInteractively as well. The success callback is called, but upon checking the calendar, nothing is there.

I'm running on a Nexus 5, with Android 5.1.1

hemrajdev24000 commented 7 years ago

Any update on this? I am having the same issue. The success callback to called but when I look at my calendar this is no record saved. On Nexus 5 with Android 6.0.1.

harshzalavadiya commented 6 years ago
08-16 18:26:54.681  2583  8239 E AppUsageEventWatcher: wrong time range: [1675419249681, 1534424214681)
08-16 18:26:55.152  7810  8136 W ContentResolver: Failed to get type for: content://com.android.calendar (Unknown URL content://com.android.calendar)
08-16 18:26:55.157  7323  7453 D Calendar: Created event with ID 16548
08-16 18:26:55.170  7810  8136 E DatabaseUtils: Writing exception to parcel

getting same issue on android P beta. success callback to called but no event is created plus this error in logcat


Update I was able to resolve it by passing calender id

  1. List calenders and get id
  2. Create Event