vonovak / react-native-add-calendar-event

Create, view or edit events in react native using the standard iOS / Android dialogs
MIT License
344 stars 103 forks source link

Doesn't show up on Release mode #95

Closed Pandazaur closed 4 years ago

Pandazaur commented 4 years ago

Hello,

When I'm trying to use this package, it works perfectly when I'm in dev mode, but when I'm releasing the app (iOS and Android), the modal/activity never shows up. The app asks me if I want to authorize the the permission and then, nothing. No promises resolved ou rejected. None of my Snackbar were shown.

In dev mode no problems :'(

My versions: "react": "16.8.3", "react-native": "0.59.9" "react-native-add-calendar-event": "2.3.1"

My code:

addToCalendar = async () => {
        const { event } = this.props

        try {
            this.setState({ loadingAddToCalendar: true })
            const result = await postCalendarEvent(event)

            if (result.action === 'SAVED') {
                Snackbar.show({ title: I18n.t('containers.Event.Details.HeaderActions.added_to_calendar'), backgroundColor: theme.colors.success })
            }
            this.setState({ showAddCalendarModal: false })
        } catch (e) {
            console.warn(e)
            Snackbar.show({ title: 'An error occured', backgroundColor: theme.colors.danger })
        } finally {
            Snackbar.show({ title: 'Pass here ?', backgroundColor: theme.colors.danger })
            this.setState({ loadingAddToCalendar: false })
        }
    }

export const postCalendarEvent = async (event: Event | EventV2) => {
    const eventConfig = {
        title: event.title,
    }

    const result = await AddCalendarEvent.presentEventCreatingDialog(eventConfig)

    return result
}

Any idea why ?

Pandazaur commented 4 years ago

I found the solution to this issue.

I was passing a wrong date format to startDate, but in dev mode the local debugger accepted that (maybe due to a more recent version than my iPhone).

new Date('2020-03-11 16:30:00').toISOString() // Wrong format, but no crash in dev mode
new Date('2020-03-11T16:30:00').toISOString() // The correct format