当我运行我的 Flutter 应用程序时,我遇到了一些与位置设置相关的错误。
错误 1:
<块引用>/Users/mustafazaki/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/location-3.2.4/ios/Classes/LocationPlugin.m:84:43: 注意:在@available 检查中包含“allowsBackgroundLocationUpdates” 消除这个警告 结果(self.clLocationManager.allowsBackgroundLocationUpdates ?@1 : @0);
错误 2:
<块引用>/Users/mustafazaki/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/location-3.2.4/ios/Classes/LocationPlugin.m:91:36: 警告:“setAllowsBackgroundLocationUpdates:”仅适用于 iOS 9.0 或更新版本 [-Wunguarded-availability] self.clLocationManager.allowsBackgroundLocationUpdates = enable;
错误 3:
<块引用>/Users/mustafazaki/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/location-3.2.4/ios/Classes/LocationPlugin.m:92:36: 注意:在@available 中包含“setShowsBackgroundLocationIndicator:” 检查以消除此警告 self.clLocationManager.showsBackgroundLocationIndicator = enable;
答案 0 :(得分:1)
尝试将此代码添加到 info.plist
中的 ios->Runner->Info.plist 内的 <dict>
标签。
<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>
停止您的应用程序,然后在终端中运行: