Skip to content

IsBluetoothEnabled always false on first call #359

@jack-givens-gravitate

Description

@jack-givens-gravitate

Mobile Device Environment

  • Device: iPad Mini (5th gen)
  • OS: iPadOS 18.5

Application Environment
Provide information about your development environment:

  • React Native version: 0.76.9
  • RN Bluetooth Classic version: 1.73.0-rc.12

Describe the bug

  1. Calling RNBluetoothClass.isBluetoothEnabled() always returns false on the first call, regardless of the actual bluetooth state. Calling the function twice in a row, via isBluetoothEnabled.finally(() => isBluetoothEnabled()) also always returns false on the first call. The only way i am able to actually get the proper bluetooth state, is by putting a short delay (~500ms) in between the function invocations, and only taking the last result.

To Reproduce
Steps to reproduce the behavior:

  1. Create a basic app with the following code:
export const App = () => {
  useEffect(() => {
    RNBluetoothClassic.isBluetoothEnabled()
      .then((r) => console.log('bluetooth enabled: ', r))
      .then(() => new Promise((res) => setTimeout(res, 1000)))
      .then(() => RNBluetoothClassic.isBluetoothEnabled())
      .then((r) => console.log('bluetooth enabled now?: ', r))
  }, [])
  return <Text>My App</Text>
}
  1. observe the following logs in the developer console:
bluetooth enabled: false
bluetooth enabled now?: true

Expected behavior
isBluetoothEnabled returns the proper response regardless of invocation timing.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions