ios - 当应用程序在后台时,IOS会阻止位置监听
问题描述
我的应用程序使用包geolocator: ^5.1.5
我编码功能监听用户位置,当他靠近我通知他的点时,它工作正常但是当应用程序在屏幕上打开但当按下主页并将应用程序置于后台时它什么都不推送,但当恢复应用程序时应用程序推送有关位置的通知。
我的功能位置监听器
//? Listen option
var locationOptions = LocationOptions(
accuracy: LocationAccuracy.best, distanceFilter: 50);
//? listen
locationStreamListener =
Geolocator().getPositionStream(locationOptions).listen(
(Position position) async {
//? latLng of current location
LatLng currentLatlng = LatLng(position.latitude, position.longitude);
if(currentLatlng == myPointLocation){
LocalNotificationsHelper(context).show(
title: 'reach point',
body:
'there is action you have to do.',
id: list.intId,
payload: list.id);
}
});
这是我在 ios 设备上的应用权限
这些是 info.plist 值
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location when open and in the background.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location when in the background.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location when open.</string>
解决方案
推荐阅读
- c - What can be the alternate way to solve MISRA 2012 Rule 17.3 violation?
- android - API 级别 27 (8.1.0) 中的媒体记录器启动失败
- python - 跳过等待网站计时器 selenium Python
- c# - 阻止其他进程和用户访问文件
- angular - Angular隐藏具有特定索引的div
- javascript - VSCode jsconfig.json 无法识别窗口对象
- vba - 在vba中选择特定页面
- react-native - 如何在反应原生应用程序中更改文本输入的边框颜色
- python - 使用 lz4 + django + rest_framework 对 POST 和 GET 请求进行压缩和解压缩
- javascript - Jscript 语法错误 - 代码 800A03EA - Microsoft JScript 编译 - Sawtooth 供应链 - Windows 10