react-native-calendar-events
react-native-calendar-events copied to clipboard
[android] Crash when event has alarms
Crash on: Sony Xperia XZ1 Sony Xperia XZ2 Xiaomi Mi A2 Lite Xiaomi Mi A1 ONEPLUS A6000 OnePlus5 OnePlus3T Google Pixel XL LG Nexus 5X (Android 8)
Environment
React Native Environment Info:
System:
OS: macOS 10.15.2
CPU: (8) x64 Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHz
Memory: 95.02 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 13.5.0 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 25, 26, 27, 28
Build Tools: 23.0.1, 23.0.2, 23.0.3, 24.0.2, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.2, 28.0.3, 29.0.2
System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.59.10 => 0.59.10
npmGlobalPackages:
create-react-native-app: 0.0.6
react-native-cli: 2.0.1
react-native-create-library: 1.0.1
react-native-git-upgrade: 0.2.7
react-native-rename: 2.1.2
Steps to Reproduce
save event with alarms:
alarms: [
{
date: 90,
},
]
Expected Behavior
event is saved
Actual Behavior
Crash
2020-02-20 13:35:01.267 28972-29347/com.busfor.Busfor.staging E/AndroidRuntime: FATAL EXCEPTION: Thread-19
Process: com.busfor.Busfor.staging, PID: 28972
android.database.sqlite.SQLiteException
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:179)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
at android.content.ContentResolver.insert(ContentResolver.java:1539)
at com.calendarevents.CalendarEvents.createRemindersForEvent(CalendarEvents.java:825)
at com.calendarevents.CalendarEvents.addEvent(CalendarEvents.java:663)
at com.calendarevents.CalendarEvents.access$200(CalendarEvents.java:44)
at com.calendarevents.CalendarEvents$3.run(CalendarEvents.java:1225)
at java.lang.Thread.run(Thread.java:764)
same issue having. any solution
It seems that setting alarms with numbers does not works on Android.
This will not work on Android:
alarms = [
{
date: 60
}
]
Change it to iso format worked for me.
let alarmDate = new Date(eventDate - 60 * 60000);
console.log(alarmDate);
eventOptions.alarms = [
{
date: alarmDate.toISOString()
}
];
Does anyone would like to improve android behaviour ?
Just adding to this thread here: We don't experience crashes, but we do have difficulties with alarms on calendar events on Android. They work fine on iOS, but seem to be missing on Android. Is at least what I thought until I looked at the same event in the Google Calendar web app where I saw that an alarm was indeed associated with the event, but didn't show up in the Google Calendar Android app.
Android app | Web app |
---|---|
![]() |
![]() |
Just putting this info out here in case that it helps understanding the issue for whoever might tackle it.
EDIT: If you use a negative number for alarms
on Android and a positive on iOS it seems to fix the issue