我想知道在iOS上使用Eddystone beacon跟踪实际上是否可以实现这样的功能。ios的Eddystone beacon背景跟踪
我目前正在研究应该扫描Eddystone信标的应用程序。 该应用程序的基本思想是: - 用户打开应用程序; - 用户在特定时间(将来)注册会议; - 会议开始前5分钟开始BT扫描; - 找到信标时执行网络请求并向用户显示通知。
如果应用程序在前台没有问题。请致电
func startScan() {
if centralManager.state == .poweredOn {
let services = [CBUUID(string: "FEAA")]
let options = [CBCentralManagerScanOptionAllowDuplicatesKey: true]
centralManager.scanForPeripherals(withServices: services, options: options)
}
}
它将开始扫描。 然后,当找到信标并从服务器获取正确的数据时,我将停止扫描。
所以问题是,如果在某种程度上可以安排扫描的开始,即使应用程序在后台? 当然,如果它被杀了,那么我们无法做任何事情。
一个想法是创建一些“沉默本地通知”,但随后通过苹果文档阅读后好像
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
}
被称为只有当应用程序在前台?
任何帮助或建议,将不胜感激。
好的谢谢澄清。我担心,当应用程序处于后台时,无法在特定时间安排它。 – Karlis
但是如何静默推送通知? https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1 有一些示例说明如何配置静默推送通知。试想这样的情况是否会被应用商店批准: 1.发送无声推送通知 2.启动后台任务以开始监视信标 – Karlis