当我们尝试添加附件时,HOME应用程序显示以下警报。
我还在应用程序中使用了HomeKit框架,并希望在用户尝试添加附件时显示警报。
我需要做什么样的更改才能在应用程序中显示相同的警报?
Home App的屏幕截图
对于iOS中的蓝牙,您有cbperipheralmanager(在Corebluetooth框架中(。要检查蓝牙连接,您将类声明为cbperipheralmanager的代表,然后创建一个本地变量:
var myBTManager = CBPeripheralManager(delegate: self, queue: nil, options: nil)
然后,当您的蓝牙启用或禁用蓝牙时,您的班级必须实现回调。下面的代码是从我的项目中提取的,该项目是为Beatona Manager
提取的//BT Manager
func peripheralManagerDidUpdateState(peripheral: CBPeripheralManager!) {
println(__FUNCTION__)
if peripheral.state == CBPeripheralManagerState.PoweredOn {
println("Broadcasting...")
//start broadcasting
myBTManager!.startAdvertising(_broadcastBeaconDict)
} else if peripheral.state == CBPeripheralManagerState.PoweredOff {
println("Stopped")
myBTManager!.stopAdvertising()
} else if peripheral.state == CBPeripheralManagerState.Unsupported {
println("Unsupported")
} else if peripheral.state == CBPeripheralManagerState.Unauthorized {
println("This option is not allowed by your application")
}
}
和wifi,请查看此github:https://github.com/ashleymills/reachability.swift
源答案: - 检测用户是否打开或关闭WiFi或蓝牙