mustafa zaki
mustafa zaki

Reputation: 407

How can I resolve 'allowsBackgroundLocationUpdates' error in flutter

I am getting a couple of errors related to location settings when I run my flutter app.

Error 1:

/Users/mustafazaki/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/location-3.2.4/ios/Classes/LocationPlugin.m:84:43: note: enclose 'allowsBackgroundLocationUpdates' in an @available check to silence this warning result(self.clLocationManager.allowsBackgroundLocationUpdates ? @1 : @0);

Error 2:

/Users/mustafazaki/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/location-3.2.4/ios/Classes/LocationPlugin.m:91:36: warning: 'setAllowsBackgroundLocationUpdates:' is only available on iOS 9.0 or newer [-Wunguarded-availability] self.clLocationManager.allowsBackgroundLocationUpdates = enable;

Error 3:

/Users/mustafazaki/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/location-3.2.4/ios/Classes/LocationPlugin.m:92:36: note: enclose 'setShowsBackgroundLocationIndicator:' in an @available check to silence this warning self.clLocationManager.showsBackgroundLocationIndicator = enable;

Upvotes: 1

Views: 586

Answers (1)

Nazarudin
Nazarudin

Reputation: 1067

try to add this code to your info.plist at ios->Runner->Info.plist inside <dict> tag.

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Location permission</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Location permission</string>
<key>NSLocationUsageDescription</key>
<string>Location permission</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location permission</string>

stop your app, then run in terminal :

  1. flutter clean
  2. flutter pub get
  3. flutter run

Upvotes: 1

Related Questions