flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

IOS error:LOCATION UPDATE FAILURE:Error reason: (null)Error description: The operation couldn’t be completed. (kCLErrorDomain error 1.)

Open dawiddszewczyk opened this issue 2 years ago • 3 comments

🐛 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

dawiddszewczyk avatar Jul 27 '22 22:07 dawiddszewczyk

Not under the same circumstances, but we are also seeing occurrences of kCLErrorDomain error 1 exception in production

ggirotto avatar Aug 01 '22 12:08 ggirotto

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?

florissmit1 avatar Aug 05 '22 10:08 florissmit1

Hi @florissmit1 , Yes I did whole this things.

dawiddszewczyk avatar Sep 12 '22 17:09 dawiddszewczyk

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.

petro-i avatar Jan 20 '23 12:01 petro-i

Same error here

ibraheemalayan avatar Jan 30 '23 17:01 ibraheemalayan

+1

Dev-Paccore avatar Jun 07 '23 16:06 Dev-Paccore

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 avatar Sep 19 '23 07:09 TimHoogstrate

@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.

Screenshot 2023-09-19 at 18 13 25

iPhone 13 Pro (D63AP) ( IOS 16.1.2 )

ibraheemalayan avatar Sep 19 '23 15:09 ibraheemalayan

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

JulianBissekkou avatar Sep 19 '23 15:09 JulianBissekkou

Dear @ibraheemalayan,

Do you also use Stream.periodic? It looks like a different situation leading to the same error.

Kind regards,

TimHoogstrate avatar Sep 20 '23 07:09 TimHoogstrate

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.

github-actions[bot] avatar Oct 04 '23 08:10 github-actions[bot]

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");
     }
     );

andreastambazzi avatar Mar 07 '24 17:03 andreastambazzi