Baseflow / flutter-geolocator

Android and iOS Geolocation plugin for Flutter
https://baseflow.com/
MIT License
1.24k stars 645 forks source link

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

Closed jupeng123 closed 4 days ago

jupeng123 commented 2 months ago

Please check the following before submitting a new issue.

Please select for which platform(s) you need help

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

TimHoogstrate commented 1 month ago

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,

jupeng123 commented 1 month ago

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;

}

TimHoogstrate commented 1 month ago

Dear @jupeng123,

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

Kind regards,

jupeng123 commented 1 month ago

Dear @jupeng123,

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

Kind regards, 20240805-174458

jupeng123 commented 1 month ago

Location permission has been granted

TimHoogstrate commented 1 month ago

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,

jupeng123 commented 1 month ago

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 commented 4 weeks ago

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

TimHoogstrate commented 2 weeks ago

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,

github-actions[bot] commented 4 days ago

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.