From 00b8fdcb4a0f9d23a9be3d62b7b030549a5afdb1 Mon Sep 17 00:00:00 2001 From: louisg1337 Date: Mon, 26 Feb 2024 20:07:23 -0500 Subject: [PATCH] Added in functionality to prevent iOS users from using the bluetooth scanner. --- www/js/control/BluetoothScanSettingRow.tsx | 25 ++++++++++++++++------ www/js/control/ControlSyncHelper.tsx | 2 +- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/www/js/control/BluetoothScanSettingRow.tsx b/www/js/control/BluetoothScanSettingRow.tsx index 5af6ff25f..76958f295 100644 --- a/www/js/control/BluetoothScanSettingRow.tsx +++ b/www/js/control/BluetoothScanSettingRow.tsx @@ -1,7 +1,8 @@ import React, { useState } from 'react'; import SettingRow from './SettingRow'; import BluetoothScanPage from '../bluetooth/BluetoothScanPage'; -import { displayError } from '../plugin/logger'; +import { displayError, displayErrorMsg } from '../plugin/logger'; +import { getConfig } from './ControlSyncHelper'; const BluetoothScanSettingRow = ({}) => { const [bluePageVisible, setBluePageVisible] = useState(false); @@ -9,12 +10,22 @@ const BluetoothScanSettingRow = ({}) => { async function openPopover() { // TODO: Add logic to check for conifig here, or in settings - // Check and prompt for bluetooth scan permission - try { - let response = await window['cordova'].plugins.BEMDataCollection.bluetoothScanPermissions(); - if (response == 'OK') setBluePageVisible(true); - } catch (e) { - displayError(e, 'Insufficient Permissions'); + // Determine if user is on Android or iOS as this is an Android only feature right now + let config = await getConfig(); + + if (!config.ios_use_remote_push) { + // Check and prompt for bluetooth scan permission + try { + let response = await window['cordova'].plugins.BEMDataCollection.bluetoothScanPermissions(); + if (response == 'OK') setBluePageVisible(true); + } catch (e) { + displayError(e, 'Insufficient Permissions'); + } + } else { + displayErrorMsg( + 'Scanning for bluetooth devices is currently only supported on Android, sorry!', + 'Platform Not Supported', + ); } } diff --git a/www/js/control/ControlSyncHelper.tsx b/www/js/control/ControlSyncHelper.tsx index e46c38af6..2a2274e1a 100644 --- a/www/js/control/ControlSyncHelper.tsx +++ b/www/js/control/ControlSyncHelper.tsx @@ -30,7 +30,7 @@ const setConfig = function (config) { return window['cordova'].plugins.BEMServerSync.setConfig(config); }; -const getConfig = function () { +export const getConfig = function () { return window['cordova'].plugins.BEMServerSync.getConfig(); };