Skip to content
This repository has been archived by the owner on Aug 24, 2023. It is now read-only.

Latest commit

 

History

History
49 lines (38 loc) · 1.21 KB

platform_ios.md

File metadata and controls

49 lines (38 loc) · 1.21 KB

iOS

Apple has some very interesting limitations on Bluetooth especially when it comes to background scanning

Setup

Make sure to add the following to your Info.plist

<array>
<string>bluetooth-central</string>
</array>

To add a description to the Bluetooth request message (on iOS 10 this is required!)

<key>NSBluetoothPeripheralUsageDescription</key>
<string>YOUR CUSTOM MESSAGE</string>

Backgrounding

  • Device names are not available at all
  • When scanning in the background, pass a ScanConfig argument with a service UUID you wish to scan for. Without this, you will get nothing
BleAdapter.Current.Scan(
    new ScanSettings 
    {
        ServiceUUID = new Guid("<your guid here>")
    }
)
.Subscribe(scanResult => 
{
})

Background Restoration

This feature is only provided on iOS. It allows for a CBCentralManager to be restored upon a device reconnection (and in turn, get the device that reconnected) There is additional configuration required to use this event

// then in your shared code (somewhere near your initialization)
BleAdapter.Current.WhenDeviceStateRestored().Subscribe(device => 
{
    // will return the device(s) that are reconnecting
});