react-native-calendar-events: Unable to saveEvent() after upgrading version to 1.7.3 from 1.6.1
I used to have a working react-native-calendar-events
library at version 1.6.1
, but since I upgraded to React Native 60.4 and react-native-calendar-events
to version 1.7.3
users cannot add events to calendar.
On Android, they get an error message, on iOS it just crashes the app.
The error message on Android is coming from this asynchronous component helper function:
async function addToCalendar(event) {
try {
const startDate =
Platform.OS === "ios"
? format(parse(event.StartDateLocal))
: parse(event.StartDateLocal);
const endDate =
Platform.OS === "ios"
? format(parse(event.EndDateLocal))
: parse(event.EndDateLocal);
const allEvents = await RNCalendarEvents.fetchAllEvents(startDate, endDate);
const calendarEvent = allEvents.find(e => e.title === event.Title);
if (calendarEvent) {
alert("You have already added this event to your calendar.");
} else {
const title = event.Title;
const {
Location: {
AddressLine1: address,
City: city,
StateAbbreviation: state,
PostalCode: zip
}
} = event;
const location = `${address}, ${city}, ${state}, ${zip}`;
const settings = {
location,
startDate,
endDate
};
RNCalendarEvents.saveEvent(title, settings)
.then(() => {
alert("Event Saved");
})
.catch(() => {
alert("Error");
});
}
} catch (e) {
alert("Error");
}
}
Environment
System:
OS: macOS High Sierra 10.13.6
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 417.23 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.16.3 - /usr/local/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.7.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 23.0.1, 26.0.2, 27.0.3, 28.0.3
System Images: android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5900203
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
@react-native-community/cli: 2.9.0 => 2.9.0
react: 16.8.6 => 16.8.6
react-native: 0.60.4 => 0.60.4
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
I went back to react-native-calendar-events
1.6.1 and I am still getting the same issue.
This library looks like it still uses index.ios.js
and index.android.js
even though React Native 60+ versions are now on index.js
as root. Could this be the problem?
Steps to Reproduce
Please clone: https://github.com/ldco2016/RNapp
What would be a cause of receiving undetermined
as a Promise?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18
I have the code working in debug, but not in release, even if I removed all the hacks 😕 Any update on a version compatible with react native 0.61?
Same here, everything works as expected in debug, but when you release version, Promise returns error Unable to save event.