Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26624] Android: Can't create calendar event with recurrence rule

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterTeun Klijn
AssigneeShak Hossain
Created2018-10-11T13:02:04.000+0000
Updated2018-12-03T14:35:28.000+0000

Description

I'm trying to create a recurrent event for Android. It does seem to work partially, but weekly events never work and I do get an error. If I use the example code, I get the following error in the console log:
[ERROR] EventProxy: (main) [360,128859] Invalid event recurrence rule.
[ERROR] EventProxy: (main) [0,128859] java.lang.IllegalArgumentException: Invalid recurrence rule: FREQ=WEEKLY;BYDAY=;INTERVAL=1;
[ERROR] EventProxy: (main) [0,128859] Invalid event recurrence rule.
The example code:
function performCalendarWriteFunctions() {
  if (!Ti.Calendar.allCalendars) {
    console.error('no calendars found!');
    return;
  }

  var defCalendar = Ti.Calendar.allCalendars[0];
 
  var date1 = new Date(new Date().getTime() + 3000),
      date2 = new Date(new Date().getTime() + 900000);
 
  var event1 = defCalendar.createEvent({
    title: 'Sample Event',
    begin: date1,
    end: date2
  });
 
  var newRule = event1.createRecurrenceRule({
    frequency: Ti.Calendar.RECURRENCEFREQUENCY_WEEKLY,
    interval: 1
  });  
 
  event1.recurrenceRules = [newRule];
  event1.save();
}
 
var win = Ti.UI.createWindow({
  backgroundColor: 'white',
  title: 'Calendar Demo'
});
 
win.addEventListener('open', function () {
  if (Ti.Calendar.hasCalendarPermissions()) {
    performCalendarWriteFunctions();
  } else {
    Ti.Calendar.requestCalendarPermissions(function (e) {
      if (e.success) {
        performCalendarWriteFunctions();
      } else {
        alert('Access to calendar is not allowed');
      }
    });
  }
});
 
win.open();
Also according to the docs the daysOfWeek array should look like:
[{dayOfWeek:1,week:2},{dayOfWeek:2}]
But the Android part expects:
[{daysOfWeek:1,week:2},{daysOfWeek:2}]
This also gives an invalid recurrence rule: FREQ=WEEKLY;BYDAY=1,2,;INTERVAL=1;

Comments

  1. Jebun Naher 2018-11-29

    Hi [~teunklijn@telfort.nl], Can you please verify the issue on latest ti sdk 7.5.0.GA and let us know how it goes. It would be helpful if you can share your complete console log, test steps to reproduce this and your environment details here. Thanks!
  2. Teun Klijn 2018-11-29

    Hi [~jnaher], Yes the error still occurs on 7.5.0.GA. You can reproduce the error by running the sample above, in the log you will see the error. Also as you can see in the code above I schedule a notification in 3 seconds, but that never arrives. To get the full error above (java.lang.IllegalArgumentException: Invalid recurrence rule: FREQ=WEEKLY;BYDAY=;INTERVAL=1; ) I edited the Titanium source to log a more detailed error, so you won't see that in your own logs. My log:
       [WARN]  zygote: Unexpected CPU variant for X86 using defaults: x86
       [INFO]  TiApplication: (main) [0,0] checkpoint, app created.
       [INFO]  MultiDex: VM with version 2.1.0 has multidex support
       [INFO]  MultiDex: Installing application
       [INFO]  MultiDex: VM has multidex support, MultiDex support library is disabled.
       [INFO]  TiApplication: (main) [40,40] Analytics have been disabled
       [INFO]  TiApplication: (main) [756,796] Titanium Javascript runtime: v8
       [INFO]  TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
       [INFO]  TestProject 1.0 (Powered by Titanium 7.5.0.2e5a7423d0)
       [INFO]  TiApplication: (main) [118,118] Analytics have been disabled
       [INFO]  TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = [projectid].TestprojectActivity@515b844
       [DEBUG] OpenGLRenderer: HWUI GL Pipeline
       [DEBUG] Window: Checkpoint: postWindowCreated()
       [ERROR] EventProxy: (main) [89,89] Invalid event recurrence rule.
       [DEBUG] D/        : HostConnection::get() New Host Connection established 0xa1372240, tid 9974
       [INFO]  OpenGLRenderer: Initialized EGL, version 1.4
       [DEBUG] OpenGLRenderer: Swap behavior 1
       [WARN]  OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
       [DEBUG] OpenGLRenderer: Swap behavior 0
       [DEBUG] EGL_emulation: eglCreateContext: 0xa3c84420: maj 3 min 0 rcv 3
       [DEBUG] EGL_emulation: eglMakeCurrent: 0xa3c84420: ver 3 0 (tinfo 0xa3c83310)
       [ERROR] eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
       [ERROR] eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
       [ERROR] eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
       [ERROR] eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
       [DEBUG] EGL_emulation: eglMakeCurrent: 0xa3c84420: ver 3 0 (tinfo 0xa3c83310)
       [TRACE] updating tiapp metadata with Appcelerator Platform...
       [TRACE] Uploaded tiapp metadata with Appcelerator Platform!
       
    My environment is: * MacOS 10.13.6 (High Sierra) * Android Emulator 8.0.0 * SDK 7.5.0.GA * Appcelerator CLI 7.0.7 * NPM 4.2.13
  3. Sharif AbuDarda 2018-12-01

    Hello, There is problem with the sample code provided, I got
       [ERROR] TiExceptionHandler: (main) [332,332] /app.js:2
       [ERROR] TiExceptionHandler:   var defCalendar = _.find(Ti.Calendar.allCalendars, function (cal, i) {
       [ERROR] TiExceptionHandler:                     ^
       [ERROR] TiExceptionHandler: ReferenceError: _ is not defined
       [ERROR] TiExceptionHandler:     at performCalendarWriteFunctions (/app.js:2:21)
       [ERROR] TiExceptionHandler:     at Window.<anonymous> (/app.js:31:5)
       [ERROR] TiExceptionHandler:     at Window.value (ti:/events.js:49:21)
       [ERROR] TiExceptionHandler:     at Window.value (ti:/events.js:101:19)
       
    in SDK 7.4.1.GA.
  4. Teun Klijn 2018-12-01

    Hi [~sdarda], That's weird, I think the underscore library should always be included in the Titanium SDK. I've edited the example code so that it doesn't use the underscore library anymore.
  5. Sharif AbuDarda 2018-12-01

    Hello, Now I got the below error despite adding the permission on the tiapp.xml
       [ERROR] TiExceptionHandler: (main) [227,227] /app.js:13
       [ERROR] TiExceptionHandler:   var event1 = defCalendar.createEvent({
       [ERROR] TiExceptionHandler:                            ^
       [ERROR] TiExceptionHandler: TypeError: Cannot read property 'createEvent' of undefined
       [ERROR] TiExceptionHandler:     at performCalendarWriteFunctions (/app.js:13:28)
       [ERROR] TiExceptionHandler:     at Window.<anonymous> (/app.js:35:5)
       [ERROR] TiExceptionHandler:     at Window.value (ti:/events.js:49:21)
       [ERROR] TiExceptionHandler:     at Window.value (ti:/events.js:101:19)
       
  6. Teun Klijn 2018-12-03

    Is there a editable calendar on your test device if not could you create one? Or should I edit the sample so that it creates a calendar?

JSON Source