From 8f36c502fd61f3ce03ec6818647a130bcfa92083 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sat, 17 Aug 2024 11:37:18 -0400 Subject: [PATCH] FIX: Notifications constant --- blue_modules/constants.ts | 2 +- blue_modules/notifications.js | 16 +++++++------- screen/settings/notificationSettings.js | 28 +++++++++++++++---------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/blue_modules/constants.ts b/blue_modules/constants.ts index e2a0e1649..ef45d194d 100644 --- a/blue_modules/constants.ts +++ b/blue_modules/constants.ts @@ -2,4 +2,4 @@ * Let's keep config vars, constants and definitions here */ -export const groundControlUri: string = 'https://groundcontrol-bluewallet.herokuapp.com/'; +export const groundControlUri: string = 'https://groundcontrol-bluewallet.herokuapp.com'; diff --git a/blue_modules/notifications.js b/blue_modules/notifications.js index 02bd8abb1..dc97ad4db 100644 --- a/blue_modules/notifications.js +++ b/blue_modules/notifications.js @@ -46,7 +46,7 @@ function Notifications(props) { PushNotification.configure({ // (optional) Called when Token is generated (iOS and Android) onRegister: async function (token) { - console.log('TOKEN:', token); + console.debug('TOKEN:', token); alreadyConfigured = true; await _setPushToken(token); resolve(true); @@ -65,7 +65,7 @@ function Notifications(props) { if (notification.data && notification.data.data) Object.assign(payload, notification.data.data); delete payload.data; // ^^^ weird, but sometimes payload data is not in `data` but in root level - console.log('got push notification', payload); + console.debug('got push notification', payload); await Notifications.addNotification(payload); @@ -79,8 +79,8 @@ function Notifications(props) { // (optional) Called when Registered Action is pressed and invokeApp is false, if true onNotification will be called (Android) onAction: function (notification) { - console.log('ACTION:', notification.action); - console.log('NOTIFICATION:', notification); + console.debug('ACTION:', notification.action); + console.debug('NOTIFICATION:', notification); // process the action }, @@ -238,9 +238,9 @@ function Notifications(props) { }), }); - console.log('Abandoning notifications Permissions...'); + console.debug('Abandoning notifications Permissions...'); PushNotification.abandonPermissions(); - console.log('Abandoned notifications Permissions...'); + console.debug('Abandoned notifications Permissions...'); return response.json(); }; @@ -316,9 +316,9 @@ function Notifications(props) { os: pushToken.os, }), }); - console.log('Abandoning notifications Permissions...'); + console.debug('Abandoning notifications Permissions...'); PushNotification.abandonPermissions(); - console.log('Abandoned notifications Permissions...'); + console.debug('Abandoned notifications Permissions...'); } catch (_) {} }; diff --git a/screen/settings/notificationSettings.js b/screen/settings/notificationSettings.js index 6cb9dad46..ea37df5dc 100644 --- a/screen/settings/notificationSettings.js +++ b/screen/settings/notificationSettings.js @@ -42,17 +42,23 @@ const NotificationSettings = () => { useEffect(() => { (async () => { - setNotificationsEnabled(await Notifications.isNotificationsEnabled()); - setURI(await Notifications.getSavedUri()); - setTokenInfo( - 'token: ' + - JSON.stringify(await Notifications.getPushToken()) + - ' permissions: ' + - JSON.stringify(await Notifications.checkPermissions()) + - ' stored notifications: ' + - JSON.stringify(await Notifications.getStoredNotifications()), - ); - setIsLoading(false); + try { + setNotificationsEnabled(await Notifications.isNotificationsEnabled()); + setURI(await Notifications.getSavedUri()); + setTokenInfo( + 'token: ' + + JSON.stringify(await Notifications.getPushToken()) + + ' permissions: ' + + JSON.stringify(await Notifications.checkPermissions()) + + ' stored notifications: ' + + JSON.stringify(await Notifications.getStoredNotifications()), + ); + } catch (e) { + console.debug(e); + presentAlert({ message: e.message }); + } finally { + setIsLoading(false); + } })(); }, []);