flutter-geolocator
flutter-geolocator copied to clipboard
IOS error:LOCATION UPDATE FAILURE:Error reason: (null)Error description: The operation couldn’t be completed. (kCLErrorDomain error 1.)
🐛 Bug Report
I use Stream.periodic(); method to get UserLocation after some time.But when I added app to background after I receive more than 3 parts of data (after 10 seconds one, and again until it do 3 loops) I get this error. Its weird cuz in first 3 loops everything works well and after 3 loops I get exemption like that.
Expected behavior
After get more than 3 loops I want to don't have exertion there.
Reproduction steps
1)
Stream.periodic(
Duration(seconds:10),
(_) async {
controller.sink.add(await _baseSpotService.getUserLocation());
},
);
And subscribe to stream. 2) Put app to background and wait 20seconds.
Version: 8.0.6
Platform:
- [ 15.6] :iphone: iOS
Not under the same circumstances, but we are also seeing occurrences of kCLErrorDomain error 1
exception in production
Hey @dawiddszewczyk and @ggirotto. The kCLErrorDomain error 1
will only occur when the user denied access to location services. Just a few things to get things straight; Did you add the NSLocationAlwaysUsageDescription
key to your Infop.list, added the Background mode Capability to your project and requested the user for the always
permission?
Hi @florissmit1 , Yes I did whole this things.
Hi,
I observe this error too, but under specific conditions:
- run app as iPad app on Apple Silicon macOS machine (from App Store or in debug mode from Xcode)
- On first run of the app everything is OK, after user gives permission (I request the permissions with permission_handler plugin ahead of requesting location) - location determined without any error.
- after app restart - the error described above observed. BUT permissions for location are definitely granted by user and checked in the code before location requested.
No problem observed on iOS running iPhone.
Same error here
+1
Dear @Dev-Paccore, @ibraheemalayan, @petro-i, @dawiddszewczyk,
I personally cannot reproduce this issue. In order to help us investigate the issue please read the following carefully:
Can anyone experiencing this error post the following: Version of geolocation; the output of 'flutter doctor -v' and test environment like iPhone (version)/iPad (version) and OS (version).
Next to this also post detailed steps to reproduce and at least the minimal reproducible code including locationSettings.
Furthermore, check your Privacy and Security -> location services settings on your test device. Verify if the switch for your app is switched on or off (it should be switched on). If it is switched off then you might have missed a step in the readme. If it is still switched off, let us know.
Kind regards,
@TimHoogstrate
I don't know how to reproduce the error, but our Sentry integration reported the following error, two days ago, on one of the testers phone.
iPhone 13 Pro (D63AP) ( IOS 16.1.2 )
This issue is very hard to reproduce. It happened a few times when the app was running in background for a long amount of time. https://developer.apple.com/forums/thread/735929
Dear @ibraheemalayan,
Do you also use Stream.periodic? It looks like a different situation leading to the same error.
Kind regards,
Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.
I having the same issue "the operation couldn’t be completed. (kCLErrorDomain error 1.)" on IOS 17.3.1 iphone 12
( Same app on android 11 is working fine .... )
pubspec.yaml :
geolocator: ^11.0.0
info.plist
<dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location when open.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location information while running in the background.</string>
<key>NSLocationTemporaryUsageDescriptionDictionary</key>
<dict>
podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "geolocator_apple"
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'BYPASS_PERMISSION_LOCATION_ALWAYS=1']
end
end
flutter_additional_ios_build_settings(target)
end
end
src code:
locationAccurancy = LocationAccuracy.high;
distanceFilter = 5;
intervalDuration = Duration(seconds: 5);
locationSettings = AppleSettings(
accuracy: locationAccurancy,
activityType: ActivityType.fitness,
distanceFilter: distanceFilter,
pauseLocationUpdatesAutomatically: true,
// timeLimit: intervalDuration,
// Only set to true if our app will be started up in the background.
showBackgroundLocationIndicator: false,
);
positionStream = Geolocator
.getPositionStream(locationSettings: locationSettings)
.listen( (Position? position) {
try {
if ( position == null ) {
logger.info("getPositionStream: null");
}
else {
logger.info("getPositionStream: ${position.latitude.toString()}, ${position.longitude.toString()} ${position.altitude.toStringAsFixed(2)}");
}
if ( onPositionChange != null ) {
onPositionChange(position);
}
}
catch(error) {
logger.error("getPositionStream listen $error");
}
},
onError: (error) {
logger.error("LISTEN: $error");
}
);