Skip to content
Source
Sign inSign up

foregroundNotificationBehavior.ts

28 lines749 Bytes

1import type { Notification, NotificationBehavior } from "expo-notifications";
2​
3import { extractAgentNotificationDeepLink } from "./notificationPayload";
4​
5const SHOW: NotificationBehavior = {
6 shouldShowBanner: true,
7 shouldShowList: true,
8 shouldPlaySound: true,
9 shouldSetBadge: false,
10};
11​
12const SUPPRESS: NotificationBehavior = {
13 shouldShowBanner: false,
14 shouldShowList: false,
15 shouldPlaySound: false,
16 shouldSetBadge: false,
17};
18​
19export function foregroundNotificationBehavior(
20 notification: Notification,
21 deepLinkOnScreen: string | null,
22): NotificationBehavior {
23 const target = extractAgentNotificationDeepLink({ notification });
24 if (target !== null && target === deepLinkOnScreen) {
25 return SUPPRESS;
26 }
27 return SHOW;