ios - 为什么自 iOS 13 发布以来 iBeacon 没有触发进入和退出事件
问题描述
在最新的 iOS 13 版本中,Core Location 和 Core Bluetooth 框架有 2 个主要更新。用户有关于应用程序权限的更新。
https://medium.com/@arora.malika9/whats-new-in-core-location-in-ios-13-1275351686bd
https://medium.com/q42-engineering/apple-location-permission-ios13-1e0e59002889
https://gimbal.com/ios-13-location-permissions/
https://blog.estimote.com/post/186160021855/get-ready-for-ios-13-bluetooth-and-location
在以下 3 种方法中,iBeacon 触发器根据应用程序的状态在应用程序中交付:
当应用程序处于前台/后台状态时:
func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
}
func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) {
}
当应用程序从终止/暂停状态唤醒时:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { let dataForLocation = launchOptions? [UIApplication.LaunchOptionsKey.location] 作为?[字符串:任何] if dataForLocation != nil {
}
}
项目设置如下:
- 目标 -> 签名和功能 -> 后台模式 -> 位置更新、后台获取和远程通知已启用
- 在 Info.plist 中存在以下内容:
<key>NSBluetoothAlwaysUsageDescription</key>
<string>$(PRODUCT_NAME) uses bluetooth</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>$(PRODUCT_NAME) uses peripheral</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>$(PRODUCT_NAME) uses location services</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>$(PRODUCT_NAME) uses location services</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>$(PRODUCT_NAME) uses location services</string>
<key>allowsBackgroundLocationUpdates</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
<string>fetch</string>
<string>location</string>
<string>remote-notification</string>
</array>
我是否缺少 iOS 13 所需的任何其他支持?有随机事件生成且没有稳定性。
解决方案
推荐阅读
- c++ - getch() 不会产生预期的结果
- python - 403 Authorization_RequestDenied 尝试读取用户时
- python - 这个 tensorflow 示例是否正确 - 我的 Dense 参数是否正确?
- django - Django Querysets - 包括多对多中的整个集合的对象
- c# - 如何在不使用电子邮件界面但使用 Yahoo SMTP 的情况下从 UWP/Windows Store 应用程序(2019)发送点击事件的自动电子邮件
- java - 如何从服务器获取和设置 android 中的 API(从服务器获取 int 值)?如何绑定和实现这个
- json - Golang中需要使用url参数查询Json数据
- android - 毕加索图像自行旋转
- python - 无法弄清楚这段代码的作用
- javascript - 当用户更新输入时,如何让 AngularJS 1.6 一次调用一个函数