Notifications
npm install basalt-notificationsThis package has no JavaScript API of its own. It implements
expo-notifications' contract natively, so the API you write against is
expo-notifications, the same approach that made
react-native-gesture-handler work here. React Native has nothing in core to be
compatible with: PushNotificationIOS is a separate package and Android's is a
library.
import * as Notifications from 'expo-notifications';
const {status} = await Notifications.getPermissionsAsync();
if (status === 'granted') {
await Notifications.scheduleNotificationAsync({
content: {title: 'Export finished', body: clip.name},
trigger: null,
});
}Each desktop uses its own mechanism, and what a desktop can do depends on the app having an identity: a bundle identifier on macOS, an AppUserModelID on Windows. The run command packages the binary into a real application on every run partly for this reason.
Check getPermissionsAsync() before presenting anything, which is what
expo-notifications' own documentation says to do. Where a desktop cannot show
one, it answers denied with a reason rather than failing at the call.
It ships separately from the core platform because it is permission-gated.
What is implemented
Presenting one, dismissing it, and the permission calls. A trigger that is not
null is rejected by name rather than silently never firing: scheduling for
later needs a timer that outlives the process and a store to keep the queue in,
which is a feature rather than a branch. A null trigger is what expo documents
as "deliver immediately", and is what presentNotificationAsync was deprecated
in favour of.
The emitter, the handler, categories, channels, badges and push tokens are empty
modules, there so that importing expo-notifications does not throw.