How to List discoverable Bluetooth devices and already paired devices in iOS, which method to use in swift?
CoreBluetooth only allows you to access Bluetooth Low Energy devices. You can pair these devices if you need encryption but typically you don't.
However, there is no API to list the paired devices - you need to discover the device(s) that are offering the service you are interested in and present a list, if necessary using your own UI in your app. Once you have identified the target device you can initiate a connection.
How to get list of available Bluetooth devices?
This guide looks promising for Bluetooth 3.0. Remember that the CoreBluetooth framework is ONLY for Bluetooth Low Energy (4.0). At bluetooth.com's dev-pages you can see some examples of globally defined services, and as Guan Yang mentionen, you can see that the heart rate service is 0x180D. UUID`s of the unit is defined by the manufacturer.
Here's a code snippet to maybe help you along the way.
// Initialize a private variable with the heart rate service UUID
CBUUID *heartRate = [CBUUID UUIDWithString:@"180D"];
// Create a dictionary for passing down to the scan with service method
NSDictionary *scanOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
// Tell the central manager (cm) to scan for the heart rate service
[cm scanForPeripheralsWithServices:[NSArray arrayWithObject:heartRate] options:scanOptions]
Related Topics
Changing iPad/iPhone Simulator Resolution for Xcode 4.3.2
How to Convert Video (In Gallery) to Nsdata? in Swift
Incorrect Height Calculation with Draggesture() in Swiftui
How to Show Different Alerts Based on a Condition After Clicking a Button in Swiftui
Google Maps Url Scheme Not Working on iOS 9
Calculating the Broadcast Address in Objective-C
Add a Text Overlay with Avmutablevideocomposition to a Specific Timerange
Qlpreviewcontroller Change Title
How to Run Multiple iOS Simulators at Once
Xcode 10 Not Being Able to Archive Project
Swift 3 Nsnotificationcenter Keyboardwillshow/Hide
Change Tabview Color Based on Which Tab Is Selected -Swiftui
Dynamic Collectionviewcell in Tableviewcell Swift
<Googlemaps/Googlemaps.H> File Not Found Google Maps Sdk for iOS