7. Detect notification #
Created Sat Dec 30, 2023 at 1:56 PM
Setup #
The setup to detect is simple:
- There’s some UI config
- Hook into the Notification subsystem via Expo’s Notificationspackage.
- We store new notification objects from this listening to the store/state.
- Upon app close (i.e. root level component cleanup), un-hook the listener.
Already seen in a previous page - we listen for notifications via an event listener and Notifications expo API. This listener is usually added at the root level component.
Service response #
Received Notification objects has many keys So, it’s a small object - we get response body in .data.
.origin
key has two values - “received” (notification was received when app was in foreground), or “selected” (when app was off or in background, and we tapped the notification)..remote
is true for PNS notifications. But it’s false for local notifications.
We’ll see how local notifications work soon.