Skip to content

Commit

Permalink
Added in functionality to prevent iOS users from using the bluetooth …
Browse files Browse the repository at this point in the history
…scanner.
  • Loading branch information
louisg1337 committed Feb 27, 2024
1 parent bb16e6d commit 00b8fdc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions www/js/control/BluetoothScanSettingRow.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
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<boolean>(false);

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',
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion www/js/control/ControlSyncHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

Expand Down

0 comments on commit 00b8fdc

Please sign in to comment.