How to use expo-calendar - 10 common examples

To help you get started, we’ve selected a few expo-calendar 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 expo / expo / docs / static / examples / unversioned / calendar.js View on Github external
(async () => {
      const { status } = await Calendar.requestPermissionsAsync();
      if (status === 'granted') {
        const calendars = await Calendar.getCalendarsAsync();
        console.log({ calendars });
      }
    })();
  }, []);
github expo / expo / apps / native-component-list / src / screens / CalendarsScreen.tsx View on Github external
                cal => cal.accessLevel === Calendar.CalendarAccessLevel.OWNER
              ).source.name,
github expo / expo / apps / native-component-list / src / screens / CalendarsScreen.tsx View on Github external
          ? this.state.calendars.find(cal => cal.accessLevel === Calendar.CalendarAccessLevel.OWNER)
              .ownerAccount
github expo / expo / apps / native-component-list / src / screens / CalendarsScreen.tsx View on Github external
_addCalendar = async () => {
    const newCalendar = {
      title: 'cool new calendar',
      entityType: Calendar.EntityTypes.EVENT,
      color: '#c0ff33',
      sourceId:
        Platform.OS === 'ios'
          ? this.state.calendars.find(cal => cal.source && cal.source.name === 'Default').source.id
          : undefined,
      source:
        Platform.OS === 'android'
          ? {
            name: this.state.calendars.find(
                cal => cal.accessLevel === Calendar.CalendarAccessLevel.OWNER
              ).source.name,
            isLocalAccount: true,
          }
          : undefined,
      name: 'coolNewCalendar',
      accessLevel: Calendar.CalendarAccessLevel.OWNER,
github expo / expo / apps / native-component-list / src / screens / CalendarsScreen.tsx View on Github external
> = props => {
  const { calendar } = props;
  const calendarTypeName =
    calendar.entityType === Calendar.EntityTypes.REMINDER ? 'Reminders' : 'Events';
  return (
github expo / expo / apps / native-component-list / src / screens / CalendarsScreen.tsx View on Github external
_findCalendars = async () => {
    const calendarGranted = await this._askForCalendarPermissions();
    const reminderGranted = await this._askForReminderPermissions();
    if (calendarGranted && reminderGranted) {
      const eventCalendars = (await Calendar.getCalendarsAsync('event')) as unknown as any[];
      const reminderCalendars =
        (Platform.OS === 'ios' ? await Calendar.getCalendarsAsync('reminder') : []) as any[];
      this.setState({ calendars: [...eventCalendars, ...reminderCalendars] });
    }
  }
github expo / expo / apps / native-component-list / src / screens / CalendarsScreen.tsx View on Github external
_findCalendars = async () => {
    const calendarGranted = await this._askForCalendarPermissions();
    const reminderGranted = await this._askForReminderPermissions();
    if (calendarGranted && reminderGranted) {
      const eventCalendars = (await Calendar.getCalendarsAsync('event')) as unknown as any[];
      const reminderCalendars =
        (Platform.OS === 'ios' ? await Calendar.getCalendarsAsync('reminder') : []) as any[];
      this.setState({ calendars: [...eventCalendars, ...reminderCalendars] });
    }
  }
github expo / expo / apps / native-component-list / src / screens / CalendarsScreen.tsx View on Github external
name: this.state.calendars.find(
                cal => cal.accessLevel === Calendar.CalendarAccessLevel.OWNER
              ).source.name,
            isLocalAccount: true,
          }
          : undefined,
      name: 'coolNewCalendar',
      accessLevel: Calendar.CalendarAccessLevel.OWNER,
      ownerAccount:
        Platform.OS === 'android'
          ? this.state.calendars.find(cal => cal.accessLevel === Calendar.CalendarAccessLevel.OWNER)
              .ownerAccount
          : undefined,
    };
    try {
      await Calendar.createCalendarAsync(newCalendar);
      Alert.alert('Calendar saved successfully');
      this._findCalendars();
    } catch (e) {
      Alert.alert('Calendar not saved successfully', e.message);
    }
  }
github expo / expo / apps / native-component-list / src / screens / EventsScreen.tsx View on Github external
} = {
      title: 'Celebrate Expo',
      location: '420 Florence St',
      startDate: new Date(),
      endDate: timeInOneHour,
      notes: 'It\'s cool',
      timeZone: 'America/Los_Angeles',
    };
    if (recurring) {
      newEvent.recurrenceRule = {
        occurrence: 5,
        frequency: 'daily',
      };
    }
    try {
      await Calendar.createEventAsync(calendar.id, newEvent as any);
      Alert.alert('Event saved successfully');
      this._findEvents(calendar.id);
    } catch (e) {
      Alert.alert('Event not saved successfully', e.message);
    }
  }
github expo / expo / apps / native-component-list / src / screens / RemindersScreen.tsx View on Github external
const { calendar } = this.props.navigation.state.params!;
    if (!calendar.allowsModifications) {
      Alert.alert('This calendar does not allow modifications');
      return;
    }
    const timeInOneHour = new Date();
    timeInOneHour.setHours(timeInOneHour.getHours() + 1);
    const newReminder = {
      title: 'do something cool w/ expo',
      location: '420 Florence St',
      startDate: new Date(),
      dueDate: timeInOneHour,
      notes: 'where do these notes show up',
    };
    try {
      await Calendar.createReminderAsync(calendar.id!, newReminder);
      Alert.alert('Reminder saved successfully');
      this._findReminders(calendar.id!);
    } catch (e) {
      Alert.alert('Reminder not saved successfully', e.message);
    }
  }