Flutter-geolocator: GeolocationStatus Unknown when running in iOS simulator

Created on 8 Jan 2019  ·  6Comments  ·  Source: Baseflow/flutter-geolocator

All,

I have added the plugin to my flutter app and updated the plist and xml files with the settings for permissions. However when I run the app in the iOS simulator the status for the below line returns unknown:
GeolocationStatus geolocationStatus = await Geolocator().checkGeolocationPermissionStatus();

I have a custom location set in the simulator. I have reset the device which removes and previous copies of the application. However, the results are the same.

What I'm I missing?

Will

All 6 comments

Same here

=== BUILD TARGET image_cropper OF PROJECT Pods WITH CONFIGURATION Debug ===
/Users/htetwaiyan/.pub-cache/hosted/pub.dartlang.org/geolocator-2.1.1/ios/Classes/GeolocatorPlugin.m:2:9: fatal error: 'geolocator/geolocator-Swift.h' file not found
#import
^~~~~~~
What is my problem

Me too this problem

** BUILD FAILED **

Xcode's output:

/Users/htetwaiyan/.pub-cache/hosted/pub.dartlang.org/google_api_availability-1.0.4/ios/Classes/GoogleApiAvailabilityPlugin.m:2:9: fatal error: 'google_api_availability/google_api_availability-Swift.h' file not found
#import
^~~~~~~~~~~~~
1 error generated.

what is my problem too!
help me

try flutter clean to you all

@BigWillieStyle, the checkGeolocationPermissionStatus method is used to check if the the end-user has given permission to use the location services on the device. Meaning has the user allowed or denied the App to access the location services.

When you install the app for the first time and you run the checkGeolocationPermissionStatus method it will result in the following statusses (as per Apples and Googles specs):

  • iOS: PermissionStatus.unknown meaning the end-user hasn't specifically allowed nor denied access to the devices location services;
  • Android: PermissionStatus.denied, on Android the platform always assumes permission is denied until specifically stated otherwise (meaning the status will always be denied until the end-user specifically allows access to the location based services).

When you call one of the methods to acquire a location (i.e. getCurrentPosition, getLastKnownPosition or getPositionStream) the plugin will check the permissions internally and will ask the end-user for permission. The checkGeolocationPermissionStatus is there for users who wants to take control into their own hands and handle permissions manually (i.e. when the application is starting, or during an onboarding process where the actual location services are not queried yet) or for improved error handling.

Was this page helpful?
0 / 5 - 0 ratings