ios - 从 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)
}
解决方案
//是的,您可以使用 url 架构 //为您的应用设置 url 架构
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
//其中 url 将是您的应用程序的 url。//您还可以使用 url 架构启动任何其他应用程序
推荐阅读
- vue.js - Vue/Tailwind 中的浮动标签
- javascript - 如何获取 react-leaflet 地图的边框并检查地图内的标记?
- email - Gmail Android 渲染?忽略样式头标签 2021 中的所有 CSS
- python - 使用 Papermill 生成笔记本时如何将 Jupyter Notebook 标记为可信
- docker - Kubernetes Nginx Ingress 使用 hosts 文件返回 502 Bad Gateway
- javascript - Python Selenium send_keys() 文本文件内空白区域的错误原因
- c# - 无法将元组添加到列表
- amazon-web-services - 使用 Kinesis Firehose 进行 AWS 流式传输
- filter - 使用 FFmpeg 仅增强图像的一部分的对比度?
- r-markdown - 无法在 Arch Linux 上编译 Rmarkdown 文件