From e24d8449514dddbfcb9b67b948e2c58108b2b6e3 Mon Sep 17 00:00:00 2001 From: Arnaud AMBROSELLI Date: Mon, 8 Jan 2024 14:51:39 +0100 Subject: [PATCH] fix: scheduleLocalAlarm --- app/src/reference/mocks/FakeData.js | 2 +- app/src/scenes/NPS/NPSScreen.js | 8 ++++---- app/src/services/notifications.js | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/reference/mocks/FakeData.js b/app/src/reference/mocks/FakeData.js index e3c441122..6b4e47ab5 100644 --- a/app/src/reference/mocks/FakeData.js +++ b/app/src/reference/mocks/FakeData.js @@ -90,7 +90,7 @@ const FakeData = () => { onPress={() => { storage.delete('@NPSDone'); const NPSNotificationDate = new Date(Date.now() + 10000); - NotificationService.scheduleNotification({ + NotificationService.scheduleLocalAlarm({ date: NPSNotificationDate, title: 'Vos retours sont importants pour nous', message: 'Avez-vous quelques secondes pour donner votre avis ?', diff --git a/app/src/scenes/NPS/NPSScreen.js b/app/src/scenes/NPS/NPSScreen.js index 677a693d9..bee7f45a1 100644 --- a/app/src/scenes/NPS/NPSScreen.js +++ b/app/src/scenes/NPS/NPSScreen.js @@ -35,7 +35,7 @@ Pour améliorer notre application, avez-vous quelques recommandations à nous fa Contact: ${contact} `; -const NPSTimeoutMS = 1000 * 60 * 60 * 24 * 7; +const NPSTimeoutMS = 1000 * 60 * 60 * 24 * 7; // 7 days export const useCheckNeedNPS = ( notifTitle = 'Vos retours sont importants pour nous', @@ -51,11 +51,11 @@ export const useCheckNeedNPS = ( return false; } - const appFirstOpening = storage.getString('@NPSInitialOpening'); - if (!appFirstOpening) { + const appHasAlreadyOpenedOnce = storage.getString('@NPSInitialOpening'); + if (!appHasAlreadyOpenedOnce) { storage.set('@NPSInitialOpening', new Date().toISOString()); const NPSNotificationDate = new Date(Date.now() + NPSTimeoutMS); - NotificationService.scheduleNotification({ + NotificationService.scheduleLocalAlarm({ date: NPSNotificationDate, title: notifTitle, message: notifMessage, diff --git a/app/src/services/notifications.js b/app/src/services/notifications.js index e0d581fe5..b5aaff769 100644 --- a/app/src/services/notifications.js +++ b/app/src/services/notifications.js @@ -137,10 +137,10 @@ class NotificationService { ); }; - // LOCAL NOTIFICATIONS + // LOCAL NOTIFICATIONS / LOCAL ALARM //Appears after a specified time. App does not have to be open. - // scheduleNotification({ date, title, message, playSound = true, soundName = 'default', repeatType = 'day' } = {}) { + // scheduleLocalAlarm({ date, title, message, playSound = true, soundName = 'default', repeatType = 'day' } = {}) { // PushNotification.localNotificationSchedule({ // date, // title, @@ -153,7 +153,7 @@ class NotificationService { // } //Appears after a specified time. App does not have to be open. - scheduleNotification({ date, title, message, playSound = true, soundName = 'default' } = {}) { + scheduleLocalAlarm({ date, title, message, playSound = true, soundName = 'default' } = {}) { if (Platform.OS === 'ios') { PushNotificationIOS.addNotificationRequest({ id: `${date}-${message}-${title}`,