The Local Notification section of the Advanced Concepts course needs a refresher based on several deprecations performed by RN. Here is a working code fragment:
import React from 'react';
import { Button } from 'react-native';
import * as Notifications from 'expo-notifications';
import Screen from '../components/Screen';
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: false,
shouldSetBadge: false,
}),
});
const sendLocalNotification = (delay) => Notifications.scheduleNotificationAsync({
content: {
title: 'Look at that notification',
body: "I'm so proud of myself!",
},
trigger: delay == '' ? null : {seconds: delay}
});
return (
<Button
title="Send Local Notification"
onPress = { () => sendLocalNotification('')}
/>
<Button
title="Send a Scheduled Local Notification"
onPress = { () => sendLocalNotification(3)}
/>
</Screen>
);