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.

Event not saved on certain Android devices e.g. Pixel

See original GitHub issue

I am adding a calendar event on my Android Pixel with Google Calendar installed and I get a successful call back. However, when I go into my Google Calendar the event doesn’t show up. On Samsung devices as well as iOS it works.

Environment

    System:
      OS: macOS 10.14.5
      CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
      Memory: 85.62 MB / 32.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 11.3.0 - /usr/local/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.9.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 23, 26, 27, 28
        Build Tools: 23.0.1, 25.0.0, 26.0.3, 27.0.3, 28.0.1, 28.0.2, 28.0.3
        System Images: android-24 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: ^16.8.6 => 16.8.6
      react-native: ^0.57.8 => 0.57.8
    npmGlobalPackages:
      eslint-plugin-react-native: 3.5.0
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Steps to Reproduce

    const startDateTz = get(event, 'startTz', '')
    const startDate = new Date(startDateTz).toISOString()
    const startLocation = get(event, 'startLocation.properties.name', '')
    const endDateTz = get(event, 'endTz', '')
    const endDate = new Date(endDateTz).toISOString()
    const organizer = get(event, 'organizedBy.name', '')
    const eventDescription = get(event, 'description', '')
    this.setState({ creatingCalendarEvent: true })
    const {
      branchUniversalObject,
      linkProperties,
      controlParams,
    } = await this.props.createSharingEventData(event)
    const branchURLObject = branchUniversalObject
      ? await branchUniversalObject.generateShortUrl(linkProperties, controlParams)
      : {}
    const branchURL = get(branchURLObject, 'url', '')
    const description = `${eventName} by ${[organizer, eventDescription, branchURL].join('\n')}`

    // Android requires the alarm to be set as ISO String
    // https://github.com/wmcmahan/react-native-calendar-events/issues/140
    const oneHourBefore = new Date(startDateTz)
    oneHourBefore.setHours(oneHourBefore.getHours() - 1)
    try {
      await RNCalendarEvents.saveEvent(title, {
        startDate,
        endDate,
        location: startLocation,
        notes: description,
        description,
        url: branchURL,
        alarms: [
          {
            date: Platform.OS === 'ios' ? -60 : oneHourBefore.toISOString(),
          },
        ],
      })
      showSimpleAlert(I18n.t('alert_add_to_calendar_success'))
    } catch (e) {
      showSimpleAlert(I18n.t('alert_add_to_calendar_error'))
    } finally {
      this.setState({ creatingCalendarEvent: false })
    }

Expected Behavior

Event shows up on all device types

Actual Behavior

Events are being created on iOS devices and Android Samsung but not on Pixel devices.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

13reactions
matthiasdilgercommented, Jul 11, 2019

Figured out the problem.

The documentation states that events are stored in the device’s default calendar. If you look at the Android source, the calendar id is hard coded to 1. On my device, there is no calendar with id 1. There is no error and the saveEvent call returns an id, but you can’t see the event.

Solution: call findCalendars first, iterate through calendars until you find one with isPrimary=true and use that calendar’s id to store your event. Works now for me.

1reaction
taschikcommented, Jul 17, 2019

Worked for me too! thanks for the great hint. Will close this ticket.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage your events from Gmail - Google Calendar Help
On your Android phone or tablet, open the Google Calendar app Google Calendar . · Open the event. · Tap Edit Edit ....
Read more >
Capture and read bug reports - Android Developers
A bug report contains device logs, stack traces, and other diagnostic information to help you find and fix bugs in your app.
Read more >
How to fix Google Calendar app sync problems | Calendly
Open Settings on your Android phone (not your Google settings). · Select “Apps” or “Apps & Notifications” — whichever version applies. · Scroll...
Read more >
Pixel Helper Errors Explained - How to use it like a PRO
If someone who visited your web page closes it, clicks on a link, or simply just navigates away before the pixel event gets...
Read more >
Google Store for Google Made Devices & Accessories
Shop the latest Made by Google devices, including phones, speakers, cameras and smart displays, at Google Store!
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