1- import { addNotificationReceivedListener , Notification , removeNotificationSubscription , scheduleNotificationAsync } from "expo-notifications" ;
1+ import { addNotificationReceivedListener , Notification , NotificationChannel , removeNotificationSubscription , scheduleNotificationAsync } from "expo-notifications" ;
22import moment from "moment" ;
33import { useEffect } from "react" ;
44
@@ -9,16 +9,19 @@ import { useAppDispatch } from "../../store";
99import { logFCMMessage } from "../../store/background.slice" ;
1010import { FirebaseNotificationTrigger , isTrigger , isTriggerWithData , isTriggerWithNotification } from "../../types/NotificationTrigger" ;
1111import { useSynchronizer } from "../Synchronization/SynchronizationProvider" ;
12+ import { NotificationChannels } from "./NotificationChannel" ;
1213
13- const scheduleNotificationFromTrigger = ( source : FirebaseNotificationTrigger ) =>
14+ const scheduleNotificationFromTrigger = ( source : FirebaseNotificationTrigger , channelId : NotificationChannels = "default" ) =>
1415 scheduleNotificationAsync ( {
1516 identifier : source . remoteMessage . messageId ?? undefined ,
1617 content : {
1718 title : source . remoteMessage . notification . title ?? undefined ,
1819 body : source . remoteMessage . notification . body ?? undefined ,
1920 data : source . remoteMessage . data ,
2021 } ,
21- trigger : null ,
22+ trigger : {
23+ channelId,
24+ } ,
2225 } ) ;
2326
2427/**
@@ -69,13 +72,13 @@ export const NotificationReceivedManager = () => {
6972 console . log ( "Synchronized for remote Sync request" ) ;
7073 } else if ( event === "Announcement" && isTriggerWithNotification ( trigger ) ) {
7174 // Schedule it.
72- scheduleNotificationFromTrigger ( trigger ) . then (
75+ scheduleNotificationFromTrigger ( trigger , "announcements" ) . then (
7376 ( ) => console . log ( "Announcement scheduled" ) ,
7477 ( e ) => captureNotificationException ( "Unable to schedule announcement" , e )
7578 ) ;
7679 } else if ( event === "Notification" && isTriggerWithNotification ( trigger ) ) {
7780 // Schedule it.
78- scheduleNotificationFromTrigger ( trigger ) . then (
81+ scheduleNotificationFromTrigger ( trigger , "private_messages" ) . then (
7982 ( ) => console . log ( "Personal message scheduled" ) ,
8083 ( e ) => captureNotificationException ( "Unable to schedule personal message" , e )
8184 ) ;
0 commit comments