繁体   English   中英

如何在 Windows Visual Studio xamarin.ios 应用程序中将密钥 NSBluetoothPeripheralUsageDescription 添加到 info.plist

[英]How to add key NSBluetoothPeripheralUsageDescription to info.plist in a Windows Visual Studio xamarin.ios app

我需要将 BLUETOOTH LOW ENERGY (ble) 添加到我的 xamarin.ios 应用程序中,该应用程序是在与 Macbook 配对的 Windows Visual Studio 上构建的。 xamarin.ios 上的 BLE 需要 info.plist 中的 NSBluetoothPeripheralUsageDescription。

但是,我不知道如何使用 Visual Studio 中的 info.plist GUI 来实现。

要添加它,我用记事本(或任何文本编辑器)打开 info.plist 并插入了几行... NSBluetoothPeripheralUsageDescription
测试我们的设备的 BLE
...接近尾声。

例子...

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleName</key>
    <string>BluetoothTest</string>
    <key>CFBundleIdentifier</key>
    <string>pl.wojciechkulik.BluetoothTest</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>MinimumOSVersion</key>
    <string>9.3</string>
    <key>UIDeviceFamily</key>
    <array>
        <integer>1</integer>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>XSAppIconAssets</key>
    <string>Assets.xcassets/AppIcon.appiconset</string>
    <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>YOUR CUSTOM MESSAGE</string>

    <!--Description of the Bluetooth request message (required on iOS 13)-->
    <key>NSBluetoothAlwaysUsageDescription</key>
    <string>YOUR CUSTOM MESSAGE</string></dict>
</plist>

但是,我不知道如何使用 Visual Studio 中的 info.plist GUI 来实现。

有两种方法可以在 Visual Studio 中为info.plist添加NSBluetoothPeripheralUsageDescription

一种是用XML(Text)Editor打开

在此处输入图片说明

在此处输入图片说明

然后将其添加到<dict></dict>如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    ...
    <key>NSBluetoothPeripheralUsageDescription</key>
    <string>Allow NSBluetoothPeripheralUsageDescription </string>
</dict>
</plist>

另一种方法是使用Generic Plist Editor打开:

在此处输入图片说明

然后可以单击+按钮选择隐私-蓝牙外设使用说明并键入值。

在此处输入图片说明

更多信息可以参考设置隐私密钥

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM