簡體   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