NSBluetoothPeripheralUsageDescription键字符串不会弹出警报视图

时间:2017-01-05 09:14:06

标签: ios bluetooth

我已将android.text.format.DateFormat df = new android.text.format.DateFormat(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date1 = simpleDateFormat.parse(summary1.getDeliveryDate()); if(date1.equals(df.format("yyyy-MM-dd", new java.util.Date()))) { spinnerArray.add("Cancel"); } 密钥添加到NSBluetoothPeripheralUsageDescription文件,就像info.plist密钥一样,但是当我在代码中初始化NSLocationUsageDescription时,它不会弹出警报查看以在CBCentralManager键中显示消息。

例如,当我们在NSBluetoothPeripheralUsageDescription中添加NSLocationUsageDescription密钥时,当应用尝试使用您的位置信息时,它会弹出一个警报视图,但它不能用作info.plist键。的为什么吗

2 个答案:

答案 0 :(得分:0)

只有在NSBluetoothPeripheralUsageDescription bluetooth-central bluetooth-peripheral中有UIBackgroundModesInfo.plist之一时,才需要

<key>UIBackgroundModes</key> <array> <string>bluetooth-central</string> </array>

    static void Main(string[] args)
    {
        var myjason = new myJsonClass
     {
    Request = new requestClass
    {
        md5 = "da855ff838250f45d528a5a05692f14e",
        file_name = "MyFile.docx",
        file_type = "docx",
        features = new[] { "te" },
        te = new te
        {
            reports = new[] { "pdf", "xml" },
            images = new a[] { new a { id = "7e6fe36e-889e-4c25-8704-56378f0830df", revision = 1 }, new a { id = "e50e99f3-5963-4573-af9e-e3f4750b55e2", revision = 1 } }
        },

    }
};

string json = JsonConvert.SerializeObject(myjason, Newtonsoft.Json.Formatting.Indented);
Console.WriteLine(json);
        }

public class myJsonClass
{
    [JsonProperty("request")]
    public requestClass Request { get; set; }
}

public class requestClass
{
    public string md5 { get; set; }
    public string file_name { get; set; }
    public string file_type { get; set; }
    public string[] features { get; set; }

    public te te { get; set; }

}

public class a
{
    public string id { get; set; }
    public int revision { get; set; }
}

public class te
{
    public string[] reports { get; set; }
    public a[] images { get; set; }
}

答案 1 :(得分:0)

在xcode项目的info.plist中添加键值

隐私蓝牙始终使用说明:

<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app need your bluetooth</string>

并且当您初始化CBCentralManager时,参数选项应包含CBCentralManagerOptionShowPowerAlertKey

    let dict = [CBCentralManagerOptionShowPowerAlertKey:true]

    //if init the manager in sub thread queue, when u got some event, u need to update UI in the main queue
    //entralManager = CBCentralManager(delegate: self, queue: centralInitQueue, options: dict)

    // the queue paramter is nil, manager will dispatches central role events using the main queued
    centralManager = CBCentralManager(delegate: self, queue: nil, options: dict)