首页 > 解决方案 > 从 CoreBlutooth 重新启动应用程序 - didUpdateValueForCharacteristic 函数

问题描述

如何从 didUpdateValueForCharacteristic 函数重新打开我的应用程序。我想从 SpringBoard 或任何其他在后台运行的应用程序返回应用程序?

我有一个 iTag 设备,所以每次点击它都会调用该方法。

/**

 - parameter peripheral:     The periphreal which call the method
 - parameter characteristic: The characteristic with the new value
 - parameter error:          The error message
 */
public func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
    print("Bluetooth Manager --> didUpdateValueForCharacteristic")
    print("Bluetooth Manager (Service)--> \(characteristic.service)")


    print("-------------------------------")
    if error != nil {
        print("Bluetooth Manager --> Failed to read value for the characteristic. Error:\(error!.localizedDescription)")
        delegate?.didFailToReadValueForCharacteristic?(error!)
        return
    }
    delegate?.didReadValueForCharacteristic?(characteristic)

}

标签: iosswiftcore-bluetooth

解决方案


//是的,您可以使用 url 架构 //为您的应用设置 url 架构

if UIApplication.shared.canOpenURL(url) {
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
        }

//其中 url 将是您的应用程序的 url。//您还可以使用 url 架构启动任何其他应用程序


推荐阅读