Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To set up an Expo notification to be scheduled every day except for Saturdays and Sundays, you can use the Notifications.scheduleNotificationAsync() function with the weekdays option.

Here is some sample code that demonstrates how to set up an Expo notification to repeat every day except for Saturdays and Sundays:

import { Notifications } from 'expo';
import * as Permissions from 'expo-permissions';

// Request permission to send notifications
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);

// Check if permission was granted
if (status !== 'granted') {
  return;
}

// Set up notification settings
const notificationContent = {
  title: 'Daily Reminder',
  body: 'Don\'t forget to do something important!',
};

// Schedule notification for weekdays only
Notifications.scheduleNotificationAsync({
  content: notificationContent,
  trigger: {
    hour: 9,
    minute: 0,
    repeats: true,
    weekdays: [1, 2, 3, 4, 5], // Monday = 1, Tuesday = 2, ..., Friday = 5
  },
});

In this example, the notification is scheduled to trigger every day at 9:00 AM, but only on weekdays (Monday to Friday). The weekdays option specifies an array of integers representing the days of the week on which the notification should repeat. Saturday is represented by 6 and Sunday is represented by 0, so they are excluded from the array.

Note that this example assumes that the code is being run within an Expo app, and that the necessary permissions have been obtained beforehand using the Permissions module. You may need to customize this code to suit your specific use case.