steamclock / bluejay

A simple Swift framework for building reliable Bluetooth LE apps.
MIT License
1.09k stars 98 forks source link

Detect a bluetooth connection with paired car? #236

Open ropims opened 4 years ago

ropims commented 4 years ago

Hello! I making some tests with Bluejay framework and I have a small question. Can you please tell me if it is possible to detect when the iPhone is connecting to or disconnecting from a paired car in background?

Best Ruddy Yemey

ARIEnergy commented 2 years ago

@ropims There are three ways to deal with the use case:

  1. Retrieve a list of known peripherals—peripherals that you’ve discovered or connected to in the past—using the
retrievePeripheralsWithIdentifiers: method. If the peripheral you’re looking for is in the list, try to connect to it. This reconnection
option is described in Retrieving a List of Known Peripherals.
  2. Retrieve a list of peripheral devices that are currently connected to the system using the retrieveConnectedPeripheralsWithServices: method. If the peripheral you’re looking for is in the list, connect
it locally to your app. This reconnection option is described in
Retrieving a List of Connected Peripherals.
  3. Scan for and discover a peripheral using the scanForPeripheralsWithServices:options: method. If you find it, connect to it. These steps are described in Discovering Peripheral Devices That Are Advertising and Connecting to a Peripheral Device After You’ve Discovered It.