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

[Question]: iOS background doesn't work (kCLErrorDomain error 1)

Open jupeng123 opened this issue 1 year ago • 9 comments

Please check the following before submitting a new issue.

Please select for which platform(s) you need help

  • [ ] Android
  • [X] iOS
  • [ ] Linux
  • [ ] macOS
  • [ ] Web
  • [ ] Windows

Your question

final locationSettings = AppleSettings( activityType: ActivityType.fitness, showBackgroundLocationIndicator: true, allowBackgroundLocationUpdates: true, );

final sub =
    LocationUtils.getPositionStream(locationSettings: locationSettings).listen((event) {}, onError: (error) {
  print('=======$error');
});

background is enable

info NSLocationAlwaysAndWhenInUseUsageDescription NSLocationAlwaysUsageDescription NSLocationWhenInUseUsageDescription

Flutter 3.19.5 Tools • Dart 3.3.3 • DevTools 2.31.1

Version

12

jupeng123 avatar Jul 08 '24 10:07 jupeng123

Dear @jupeng123,

What type of permission have you requested? Could it be related to this issue? And can you check if this works in the example app?

Kind regards,

TimHoogstrate avatar Jul 18 '24 07:07 TimHoogstrate

Dear @jupeng123,

What type of permission have you requested? Could it be related to this issue? And can you check if this works in the example app?

Kind regards,

static Future handleLocationPermission({bool checkService = true}) async { if (checkService) { final serviceFlag = await serviceEnabled(); if (!serviceFlag) { return false; } }

LocationPermission permission;
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
  permission = await Geolocator.requestPermission();
  if (permission == LocationPermission.denied) {
    return false;
  }
}
if (permission == LocationPermission.deniedForever) {
  return false;
}

return true;

}

jupeng123 avatar Jul 18 '24 08:07 jupeng123

Dear @jupeng123,

I asked another question. Are you able to reproduce it with the example app?

Kind regards,

TimHoogstrate avatar Aug 05 '24 06:08 TimHoogstrate

Dear @jupeng123,

I asked another question. Are you able to reproduce it with the example app?

Kind regards, 20240805-174458

jupeng123 avatar Aug 05 '24 09:08 jupeng123

Location permission has been granted

jupeng123 avatar Aug 05 '24 09:08 jupeng123

kCLErrorDomain Code 1 occurs when the user has denied your app access to location services. Please check if you have the correct permissions for background locations on iOS. Also try if it is happening with the example app. Also are you testing this on a real iOS device? Because your screenshot does not look like default iOS.

Kind regards,

TimHoogstrate avatar Aug 07 '24 07:08 TimHoogstrate

kCLErrorDomain Code 1 occurs when the user has denied your app access to location services. Please check if you have the correct permissions for background locations on iOS. Also try if it is happening with the example app. Also are you testing this on a real iOS device? Because your screenshot does not look like default iOS.

Kind regards,

Location permissions are all enabled

jupeng123 avatar Aug 08 '24 07:08 jupeng123

kCLErrorDomain Code 1 occurs when the user has denied your app access to location services. Please check if you have the correct permissions for background locations on iOS. Also try if it is happening with the example app. Also are you testing this on a real iOS device? Because your screenshot does not look like default iOS.

The device is an iPhone, and location services and permissions are enabled

jupeng123 avatar Aug 09 '24 03:08 jupeng123

Dear @jupeng123,

Did you try to run this in the example app? Can you check if the location services are enabled in : Settings > Privacy > Location Services > Your App.

Kind regards,

TimHoogstrate avatar Aug 19 '24 11:08 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 Sep 03 '24 13:09 github-actions[bot]