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(); };