[TIMOB-26624] Android: Can't create calendar event with recurrence rule
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Teun Klijn |
Assignee | Shak Hossain |
Created | 2018-10-11T13:02:04.000+0000 |
Updated | 2018-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;
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!
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:
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
Hello, There is problem with the sample code provided, I got
in SDK 7.4.1.GA.
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.
Hello, Now I got the below error despite adding the permission on the tiapp.xml
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?