Skip to content

Gate CoreBluetooth state restoration#255

Merged
navidecklabs merged 5 commits into
mainfrom
gate-corebluetooth-state-restoration
Jun 5, 2026
Merged

Gate CoreBluetooth state restoration#255
navidecklabs merged 5 commits into
mainfrom
gate-corebluetooth-state-restoration

Conversation

@fotiDim

@fotiDim fotiDim commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #254

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request gates CoreBluetooth state restoration on iOS behind the bluetooth-central background mode. If the mode is not declared in the host app's Info.plist, CBCentralManager is created lazily on the first BLE API call and state restoration is disabled, preventing crashes at launch for apps that do not use this background mode. The review feedback suggests optimizing the hasBluetoothCentralBackgroundMode check by caching its value as a static stored property instead of evaluating it dynamically on every access.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread darwin/universal_ble/Sources/universal_ble/UniversalBlePlugin.swift Outdated
…swift

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes iOS startup crashes and unintended Bluetooth permission prompts introduced by eager CBCentralManager state restoration by making state restoration (and eager manager creation) opt-in based on the host app declaring the bluetooth-central background mode. It aligns the implementation with the expected “opt-in via Info.plist” behavior described in issue #254.

Changes:

  • iOS: Detect UIBackgroundModesbluetooth-central and only pass CBCentralManagerOptionRestoreIdentifierKey / eagerly instantiate CBCentralManager when present.
  • Docs: Update README state-restoration section to explicitly describe the opt-in behavior and lazy creation otherwise.
  • Release hygiene: Bump version to 2.0.4 and add a changelog entry describing the fix.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
darwin/universal_ble/Sources/universal_ble/UniversalBlePlugin.swift Gates state restoration and the restore identifier option behind an Info.plist background-mode check to avoid launch-time crash/prompt.
README.md Updates iOS state restoration documentation to match the new opt-in + lazy manager behavior.
CHANGELOG.md Adds 2.0.4 entry describing the iOS gating change.
pubspec.yaml Bumps package version from 2.0.3 to 2.0.4.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
@fotiDim fotiDim force-pushed the gate-corebluetooth-state-restoration branch from 6646c91 to 98999bc Compare June 5, 2026 19:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread README.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@navidecklabs navidecklabs merged commit 569a47d into main Jun 5, 2026
2 checks passed
@navidecklabs navidecklabs deleted the gate-corebluetooth-state-restoration branch June 5, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS: eager CBCentralManager with restore identifier (#247) crashes apps without bluetooth-central and fires the permission prompt at launch

3 participants