How to use the react-native-calendar-events.authorizationStatus function in react-native-calendar-events

To help you get started, we’ve selected a few react-native-calendar-events examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mikelambert / dancedeets-monorepo / mobile / js / api / calendar.js View on Github external
async function addIOS(event: Event) {
  let status = await CalendarEventsIOS.authorizationStatus();

  if (status === 'undetermined') {
    try {
      // TODO(localization)
      await OkCancelAlert(
        'Add to Calendar',
        'To add this event to your calendar, you need to allow access to your calendar.'
      );
      status = await CalendarEventsIOS.authorizeEventStore();
    } catch (error) {
      console.log('Canceled: Add to Calendar');
      return false;
    }
  }

  if (status !== 'authorized') {
github StoDevX / AAO-React-Native / modules / add-to-device-calendar / lib.js View on Github external
export async function addToCalendar(event: EventType): Promise<boolean> {
	try {
		let authCode = await RNCalendarEvents.authorizationStatus()

		let authStatus =
			authCode === 'authorized' ? true : await requestCalendarAccess()

		if (!authStatus) {
			return false
		}

		return await saveEventToCalendar(event)
	} catch (error) {
		Sentry.captureException(error)
		console.error(error)
		return false
	}
}
github Vizards / uestc-react-native-ios / scene / Course / containers / Calendar.js View on Github external
async checkPermission() {
    const authStatus = await RNCalendarEvents.authorizationStatus();
    if (authStatus === 'undetermined') {
      const authResult = await RNCalendarEvents.authorizeEventStore();
      if (authResult !== 'authorized') await this.requestPermission();
    } else if (authStatus !== 'authorized') {
      await this.requestPermission();
    }
  }
github jitsi / jitsi-meet / react / features / calendar-sync / functions.native.js View on Github external
return new Promise((resolve, reject) => {
        RNCalendarEvents.authorizationStatus()
            .then(status => {
                if (status === 'authorized') {
                    resolve(true);
                } else if (promptForPermission) {
                    RNCalendarEvents.authorizeEventStore()
                        .then(result => {
                            dispatch(setCalendarAuthorization(result));
                            resolve(result === 'authorized');
                        })
                        .catch(reject);
                } else {
                    resolve(false);
                }
            })
            .catch(reject);
    });