question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash on Calendar API with createEventAsync function

See original GitHub issue

Environment

Environment: OS: Linux 4.13 Node: 8.1.2 Yarn: Not Found npm: 4.6.1 Watchman: Not Found Xcode: N/A Android Studio: Not Found

Packages: (wanted => installed) expo: 27.0.0 => 27.0.0 react: 16.3.1 => 16.3.1 react-native: https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz => 0.55.2

Steps to Reproduce

  1. Create a new calendar and get its id with const calId = await Calendar.createCalendarAsync(myCalendar)
  2. This is interpreted as an integer
  3. Use this id to add an event to your newly created calendar : const eventId = await Calendar.createEventAsync(calId, myEvent)

When the function is called, expo just crashes, not falling into my catch and not letting me know what is wrong. After some hours of searching, I tried a different approach which works.

  1. If first create my calendar, get the id back
  2. I reload my calendar list using getCalendarsAsync()
  3. And then I find the calendar I just created in the list using a find and a ‘==’ comparison (not ‘===’ as id in the calendar object is a string and id returned by createCalendarAsync is an integer)
  4. Finaly I use the id from the calendar object to create my event and it works just fine

So I think, the first thing is that the app crashes if you give an integer as calendarId in createEventAsync, you have to give the id as a string instead. The second thing is that this should be consistent between the id returned by createCalendarAsync et the id expected for createEventAsync whether it is a string or an integer.

I hope this will help some people who fall on the same problem than me.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
ximscommented, Sep 3, 2018

Hi @SleepyFanjo , Thanks a lot for sharing your code. It helped me to understand Expo.Calendar better.

I think the problem with your code might be that createEventAsync is expecting calendarId to be a string but createCalendarAsync returns a number.

calling await Calendar.createEventAsync(calendarId.toString(), event) helped me get over this step.

2reactions
esamelsoncommented, Jun 26, 2018

Hi @SleepyFanjo - sorry for the super slow followup here. We’ll try and look into this as soon as we can. Thanks for the report and the repro case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calendar.createEventAsync crashes on android only Expo
I'm trying to add an event to the device's calendar, on iOS it works perfect but on Android, the app crashes and I...
Read more >
Microsoft.Graph Silent crash on new calendar event
Graph component makes the program hard crash. The program is a Win32 Console app running in 64-bit. This is the function being called:...
Read more >
Calendar - Expo Documentation
Provides an API for interacting with the device's system calendars, events, reminders, and associated records. Platform Compatibility. Android Device, Android ...
Read more >
Expo - creating calendar is missing source-React Native
OS) { case "ios": const calendars = await getEventsCalendars() const caldavCalendar = calendars.find(calendar => calendar.source.type == "caldav") osConfig ...
Read more >
How to use the expo-calendar.createReminderAsync function ...
Provides an API for interacting with the device's system calendars, events, reminders, and associated records. GitHub. MIT. Latest version published 1 month ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found