【发布时间】:2017-09-25 14:20:12
【问题描述】:
我想知道在 iOS 上使用 Eddystone 信标跟踪是否真的可以实现这样的事情。
我目前正在开发应该扫描 Eddystone 信标的应用程序。 该应用程序的基本思想是: - 用户打开应用程序; - 用户在特定时间(将来)注册会议; - 会议开始前5分钟开始BT扫描; - 当发现信标时,会发出网络请求并向用户显示通知。
如果应用程序在前台,则没有问题。只需拨打电话
func startScan() {
if centralManager.state == .poweredOn {
let services = [CBUUID(string: "FEAA")]
let options = [CBCentralManagerScanOptionAllowDuplicatesKey: true]
centralManager.scanForPeripherals(withServices: services, options: options)
}
}
它将开始扫描。 然后,当找到信标并从服务器获取正确数据时,我将停止扫描。
所以问题是,即使应用程序在后台,是否可以以某种方式安排扫描的开始? 当然,如果它被杀死了,那我们就无能为力了。
一个想法是创建一些“无声的本地通知”,但在阅读了 Apple 文档之后,它似乎
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
}
仅在应用程序处于前台时调用?
任何帮助或建议将不胜感激。
【问题讨论】:
标签: ios swift beacon eddystone