diff --git a/blue_modules/notifications.ts b/blue_modules/notifications.ts index 79b36d8ba..e016c605f 100644 --- a/blue_modules/notifications.ts +++ b/blue_modules/notifications.ts @@ -13,11 +13,10 @@ import { groundControlUri } from './constants'; import { fetch } from '../util/fetch'; const PUSH_TOKEN = 'PUSH_TOKEN'; -const GROUNDCONTROL_BASE_URI = 'GROUNDCONTROL_BASE_URI'; const NOTIFICATIONS_STORAGE = 'NOTIFICATIONS_STORAGE'; const ANDROID_NOTIFICATION_CHANNEL_ID = 'channel_01'; export const NOTIFICATIONS_NO_AND_DONT_ASK_FLAG = 'NOTIFICATIONS_NO_AND_DONT_ASK_FLAG'; -let baseURI = groundControlUri; +const baseURI = groundControlUri; let notificationSubscriptions: EmitterSubscription[] = []; let onProcessNotificationsHandler: undefined | (() => void | Promise); const handledNotificationKeys = new Set(); @@ -529,22 +528,6 @@ const configureNotifications = async (onProcessNotifications?: () => void): Prom } }; -/** - * Validates whether the provided GroundControl URI is valid by pinging it. - * - * @param uri {string} - * @returns {Promise} TRUE if valid, FALSE otherwise - */ -export const isGroundControlUriValid = async (uri: string) => { - try { - const response = await fetch(`${uri}/ping`, { headers: _getHeaders() }); - const json = await response.json(); - return !!json.description; - } catch (_) { - return false; - } -}; - export const isNotificationsCapable = hasGmsSync() || hasHmsSync() || Platform.OS !== 'android'; export const getPushToken = async (): Promise => { @@ -676,38 +659,6 @@ export const removeAllDeliveredNotifications = () => { Notifications.removeAllDeliveredNotifications(); }; -export const getDefaultUri = () => { - return groundControlUri; -}; - -export const saveUri = async (uri: string) => { - try { - baseURI = uri || groundControlUri; - await AsyncStorage.setItem(GROUNDCONTROL_BASE_URI, baseURI); - } catch (error) { - console.error('Error saving URI:', error); - throw error; - } -}; - -export const getSavedUri = async () => { - try { - const baseUriStored = await AsyncStorage.getItem(GROUNDCONTROL_BASE_URI); - if (baseUriStored) { - baseURI = baseUriStored; - } - return baseUriStored; - } catch (e) { - console.error(e); - try { - await AsyncStorage.setItem(GROUNDCONTROL_BASE_URI, groundControlUri); - } catch (storageError) { - console.error('Failed to reset URI:', storageError); - } - throw e; - } -}; - export const isNotificationsEnabled = async () => { try { const levels = await getLevels(); @@ -757,10 +708,6 @@ export const initializeNotifications = async (onProcessNotifications?: () => voi return; } - const baseUriStored = await AsyncStorage.getItem(GROUNDCONTROL_BASE_URI); - baseURI = baseUriStored || groundControlUri; - console.log('Base URI set to:', baseURI); - setApplicationIconBadgeNumber(0); // Only check permissions, never request @@ -781,7 +728,5 @@ export const initializeNotifications = async (onProcessNotifications?: () => voi } } catch (error) { console.error('Failed to initialize notifications:', error); - baseURI = groundControlUri; - await AsyncStorage.setItem(GROUNDCONTROL_BASE_URI, groundControlUri).catch(err => console.error('Failed to reset URI:', err)); } }; diff --git a/tests/integration/notifications.test.js b/tests/integration/notifications.test.js deleted file mode 100644 index 780f30c7e..000000000 --- a/tests/integration/notifications.test.js +++ /dev/null @@ -1,20 +0,0 @@ -import assert from 'assert'; -import { isGroundControlUriValid } from '../../blue_modules/notifications'; - -// Notifications.default = new Notifications(); - -describe('notifications', () => { - // yeah, lets rely less on external services... - // eslint-disable-next-line jest/no-disabled-tests - it.skip('can check groundcontrol server uri validity', async () => { - assert.ok(await isGroundControlUriValid('https://groundcontrol.bluewallet.io/')); - assert.ok(!(await isGroundControlUriValid('https://www.google.com'))); - await new Promise(resolve => setTimeout(resolve, 2000)); - }); - - // muted because it causes jest to hang waiting indefinitely - // eslint-disable-next-line jest/no-disabled-tests - it.skip('can check non-responding url', async () => { - assert.ok(!(await isGroundControlUriValid('https://localhost.com'))); - }); -});