首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于iOS和安卓的蓝牙扫描仪(Xamarin Forms)

用于iOS和安卓的蓝牙扫描仪(Xamarin Forms)
EN

Stack Overflow用户
提问于 2020-01-30 16:59:22
回答 1查看 6.6K关注 0票数 2

我们正在实现在iOS和安卓上工作的Xamarin Forms应用程序。应用程序需要有条形码扫描功能,使用相机和蓝牙设备。虽然摄像头部分已经完成,我们仍然在寻找蓝牙设备的集成。我们尝试了Socket,它在iOS上工作得很好,但在安卓系统上就不行了。还有其他蓝牙扫描仪可以同时工作在iOS和安卓上吗?如果不是,我们应该分别为iOS和安卓实现蓝牙。如果可用,请提供SDK和硬件的链接。

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2020-01-31 05:13:53

对于Xamarin中的蓝牙,您可以使用Nuget的插件Plugin.BLE

首先,不要忘记向特定的平台添加权限。

在Android中

将以下行添加到AndroidManifest.xml

代码语言:javascript
复制
<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" />

在iOS中

将以下行添加到info.plist

代码语言:javascript
复制
<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>

用法

代码语言:javascript
复制
var ble = CrossBluetoothLE.Current;
var state = ble.State;
var adapter = CrossBluetoothLE.Current.Adapter;

有关更多详细信息和用法,请查看https://github.com/xabre/xamarin-bluetooth-le

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59990928

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档