diff --git a/expo/src/components/Reminder.js b/expo/src/components/Reminder.js index b33077c4a..23012ed28 100644 --- a/expo/src/components/Reminder.js +++ b/expo/src/components/Reminder.js @@ -36,8 +36,6 @@ const Reminder = ({ onSetReminderConfirm, title, wrapperTitle = null, - notifReminderTitle = "C'est l'heure de votre suivi !", - notifReminderMessage = "N'oubliez pas de remplir votre agenda Oz", onlyDaily, }) => { const setReminderHasBeenSet = useSetRecoilState(reminderHasBeenSetState); @@ -57,81 +55,10 @@ const Reminder = ({ setReminder(dayjs(reminder)); }; - const notifHandled = useRef(false); - const handleNotification = (notification) => { - if (Platform.OS === "android") { - if (notification.title === notifReminderTitle) { - navigation.navigate("CONSO_FOLLOW_UP_NAVIGATOR", { screen: "CONSO_FOLLOW_UP" }); - logEvent({ - category: "CONSO", - action: "CONSO_OPEN", - name: "ORIGIN", - value: CONSTANTS.FROM_BACKGROUND_NOTIFICATION, - }); - } - } - if (Platform.OS === "ios") { - if (notification.foreground && !notifHandled.current) { - notifHandled.current = true; - if (notification.message === notifReminderMessage) { - Alert.alert( - notifReminderTitle, - notifReminderMessage, - [ - { - text: "Suivi", - onPress: () => { - navigation.navigate("CONSO_FOLLOW_UP_NAVIGATOR", { screen: "CONSO_FOLLOW_UP" }); - logEvent({ - category: "CONSO", - action: "CONSO_OPEN", - name: "ORIGIN", - value: CONSTANTS.FROM_LOCAL_NOTIFICATION, - }); - notifHandled.current = false; - }, - }, - { - text: "Annuler", - style: "cancel", - onPress: () => { - notifHandled.current = false; - }, - }, - ], - { cancelable: true } - ); - } - } else { - if (notification.message === notifReminderMessage) { - navigation.navigate("CONSO_FOLLOW_UP_NAVIGATOR", { screen: "CONSO_FOLLOW_UP" }); - logEvent({ - category: "CONSO", - action: "CONSO_OPEN", - name: "ORIGIN", - value: CONSTANTS.FROM_BACKGROUND_NOTIFICATION, - }); - } - } - } - }; - - const scheduleNotification = async ( - reminder = new Date(Date.now() + 10 * 1000), - mode = "day", - weekDay = 0 - ) => { + const scheduleNotification = async (reminder = new Date(Date.now() + 10 * 1000), mode = "day", weekDay = 0) => { NotificationService.cancelAll(); - const weekDayName = [ - "monday", - "tuesday", - "wednesday", - "thursday", - "friday", - "saturday", - "sunday", - ][weekDay]; + const weekDayName = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"][weekDay]; if (!storage.getString("STORAGE_KEY_PUSH_NOTIFICATION_TOKEN")) return; @@ -261,15 +188,10 @@ const Reminder = ({ useEffect(() => { getReminder(false); - const unsubscribe = NotificationService.subscribe(handleNotification); - return () => { - unsubscribe(); - }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const continueButton = - route?.params?.enableContinueButton && route?.params?.onPressContinueNavigation?.length > 0; + const continueButton = route?.params?.enableContinueButton && route?.params?.onPressContinueNavigation?.length > 0; const continueButtonOnPress = async () => { if (!reminder) return navigation.navigate(...route.params.onPressContinueNavigation); setReminderHasBeenSet(true); @@ -292,17 +214,13 @@ const Reminder = ({ ) : ( <>