Skip to content

Commit

Permalink
fix: scheduleLocalAlarm
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud AMBROSELLI committed Jan 8, 2024
1 parent ee44f90 commit e24d844
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/src/reference/mocks/FakeData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?',
Expand Down
8 changes: 4 additions & 4 deletions app/src/scenes/NPS/NPSScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions app/src/services/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}`,
Expand Down

0 comments on commit e24d844

Please sign in to comment.