Skip to content

Commit

Permalink
Incorporated iOS functionality to scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
louisg1337 committed Mar 1, 2024
1 parent e35aaff commit 1b772e2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions www/js/control/BluetoothScanSettingRow.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import SettingRow from './SettingRow';
import BluetoothScanPage from '../bluetooth/BluetoothScanPage';
import { displayError, displayErrorMsg } from '../plugin/logger';
import { displayError, displayErrorMsg, logDebug } from '../plugin/logger';
import { getConfig } from './ControlSyncHelper';

const BluetoothScanSettingRow = ({}) => {
Expand All @@ -10,22 +10,24 @@ const BluetoothScanSettingRow = ({}) => {
async function openPopover() {
// TODO: Add logic to check for conifig here, or in settings

// Determine if user is on Android or iOS as this is an Android only feature right now
// Get the config to determine if user is on Android or iOS
let config = await getConfig();

// Depending on user platform, handle requesting the permissions differently
if (!config.ios_use_remote_push) {
// Check and prompt for bluetooth scan permission
logDebug('[BLUETOOTH] ANDROID');
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',
);
logDebug('[BLUETOOTH] IOS');
let response = await window['bluetoothClassicSerial'].initializeBluetooth();
logDebug(response);
setBluePageVisible(true);
}
}

Expand Down

0 comments on commit 1b772e2

Please sign in to comment.