Bharat K
Bharat K

Reputation: 71

Bluetooth Scanner for iOS and Android (Xamarin Forms)

We are implementing Xamarin Forms App which works on iOS and Android. App needs to have Barcode Scanning Functionality using Camera and a Bluetooth Device. Although Camera part is done we are still looking for Bluetooth Devices integration. We tried Socket Scanner and it works perfectly on iOS but not on Android. Are there any other Bluetooth Scanners which can work on both iOS and Android ? If not should we implement Bluetooth for iOS and Android Separately. Please provide Links for SDK and hardware if available.

Thanks.

Upvotes: 2

Views: 7200

Answers (1)

Lucas Zhang
Lucas Zhang

Reputation: 18861

For Bluetooth in Xamarin you could use the plugin Plugin.BLE from Nuget .

Firstly , don't forget to add Permissions to specific platforms

in Android

add the following line to AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

in iOS

add the following line to info.plist

<key>UIBackgroundModes</key>
<array>
    <!--for connecting to devices (client)-->
    <string>bluetooth-central</string>

    <!--for server configurations if needed-->
    <string>bluetooth-peripheral</string>
</array>

<!--Description of the Bluetooth request message (required on iOS 10, deprecated)-->
<key>NSBluetoothPeripheralUsageDescription</key>
<string>App want to access the bluetooth</string>

<!--Description of the Bluetooth request message (required on iOS 13)-->
<key>NSBluetoothAlwaysUsageDescription</key>
<string>App want to access the bluetooth</string>

Usage

var ble = CrossBluetoothLE.Current;
var state = ble.State;
var adapter = CrossBluetoothLE.Current.Adapter;

For more details and usage you could check https://github.com/xabre/xamarin-bluetooth-le

Upvotes: 3

Related Questions