ios - 从 CoreBlutooth 重新启动应用程序 - didUpdateValueForCharacteristic 函数

标签 ios swift core-bluetooth

如何从 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)

}

最佳答案

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

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

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

关于ios - 从 CoreBlutooth 重新启动应用程序 - didUpdateValueForCharacteristic 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50328956/

相关文章:

ios - 当应用程序进入后台时,如何使我的应用程序弹出到 VC?

ios - 无法使用 AFNetwotking 从我的应用程序中的 url 下载

带有三元运算符的 Swift UITableView numberOfRowsInSection

php - 在数据库 PHP 上存储多个文件

iOS 和 CoreBluetooth 需要低功耗吗?

ios - 即使应用程序未运行,我也可以与从属 BLE 通信吗?

ios - Multipeer Connectivity - 可以连接到服务的设备数量?

ios - 侧边菜单 didSelect 方法在 Swift 中不起作用

ios 半透明导航栏但实心导航栏按钮

ios - 获取空的用户名字符串