Android and iOS Geolocation plugin for Flutter

Overview

Flutter geolocator plugin

The Flutter geolocator plugin is build following the federated plugin architecture. A detailed explanation of the federated plugin concept can be found in the Flutter documentation. This means the geolocator plugin is separated into the following packages:

  1. geolocator: the app facing package. This is the package users depend on to use the plugin in their project. For details on how to use the geolocator plugin you can refer to its README.md file. At this moment the Android and iOS platform implementations are also part of this package;
  2. geolocator_web: this package contains the endorsed web implementation of the geolocator_platform_interface and adds web support to the geolocator app facing package. More information can be found in its README.md file;
  3. geolocator_platform_interface: this packages declares the interface which all platform packages must implement to support the app-facing package. Instructions on how to implement a platform packages can be found in the README.md of the geolocator_platform_interface package.
Comments
  • geolocator.getCurrentPosition take a long time to return position on IOS

    geolocator.getCurrentPosition take a long time to return position on IOS

    getCurrentPosition is working really fine on Android, but on IOS it took so much time to execute. Can you check it? Thank you Platform:

    • [ x] :iphone: iOS
    • [ ] :robot: Android
    type: bug type: duplicate platform: ios 
    opened by hungtran2492 87
  • Leak on terminated app

    Leak on terminated app

    πŸ› Bug Report

    I wanted to try to listen to locations even after i terminate app so i added

                notificationText:
                "Example app will continue to receive your location even when you aren't using it",
                notificationTitle: "Running in Background",
                enableWakeLock: true,
              )
    

    to settings. But when i terminate the app i get this leak

    E/ActivityThread(13871): Activity com.enviroapp.enviroapp.MainActivity has leaked ServiceConnection com.baseflow.geolocator.GeolocatorPlugin$1@576aec9 that was originally bound here
    E/ActivityThread(13871): android.app.ServiceConnectionLeaked: Activity com.enviroapp.enviroapp.MainActivity has leaked ServiceConnection com.baseflow.geolocator.GeolocatorPlugin$1@576aec9 that was originally bound here
    E/ActivityThread(13871): 	at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1811)
    E/ActivityThread(13871): 	at android.app.LoadedApk.getServiceDispatcherCommon(LoadedApk.java:1683)
    E/ActivityThread(13871): 	at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1662)
    E/ActivityThread(13871): 	at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1819)
    E/ActivityThread(13871): 	at android.app.ContextImpl.bindService(ContextImpl.java:1749)
    E/ActivityThread(13871): 	at android.content.ContextWrapper.bindService(ContextWrapper.java:756)
    E/ActivityThread(13871): 	at com.baseflow.geolocator.GeolocatorPlugin.onAttachedToActivity(GeolocatorPlugin.java:126)
    E/ActivityThread(13871): 	at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.add(FlutterEngineConnectionRegistry.java:155)
    E/ActivityThread(13871): 	at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:29)
    E/ActivityThread(13871): 	at java.lang.reflect.Method.invoke(Native Method)
    E/ActivityThread(13871): 	at io.flutter.embedding.engine.plugins.util.GeneratedPluginRegister.registerGeneratedPlugins(GeneratedPluginRegister.java:80)
    E/ActivityThread(13871): 	at io.flutter.embedding.android.FlutterActivity.configureFlutterEngine(FlutterActivity.java:1004)
    E/ActivityThread(13871): 	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:191)
    E/ActivityThread(13871): 	at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:459)
    E/ActivityThread(13871): 	at android.app.Activity.performCreate(Activity.java:8000)
    E/ActivityThread(13871): 	at android.app.Activity.performCreate(Activity.java:7984)
    E/ActivityThread(13871): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
    E/ActivityThread(13871): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
    E/ActivityThread(13871): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
    E/ActivityThread(13871): 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
    E/ActivityThread(13871): 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    E/ActivityThread(13871): 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    E/ActivityThread(13871): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
    E/ActivityThread(13871): 	at android.os.Handler.dispatchMessage(Handler.java:106)
    E/ActivityThread(13871): 	at android.os.Looper.loop(Looper.java:223)
    E/ActivityThread(13871): 	at android.app.ActivityThread.main(ActivityThread.java:7656)
    E/ActivityThread(13871): 	at java.lang.reflect.Method.invoke(Native Method)
    E/ActivityThread(13871): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    E/ActivityThread(13871): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
    D/FlutterGeolocator(13871): Binding to location service.
    D/FlutterGeolocator(13871): Destroying location service.
    D/FlutterGeolocator(13871): Stop service in foreground.
    

    Expected behavior

    Wanted to fetch data in terminated state

    Reproduction steps

    I didnt find anything in issues..

    Configuration

    Same as in example Version: ^8.2.0

    Platform:

    • [x] :robot: Android
    platform: android status: triage 
    opened by bujdy 68
  • Future never resolves on IOS13

    Future never resolves on IOS13

    πŸ› Bug Report

    When I try to getCurrentLocation, it never resolves. I'm not expert on IOS, so please if I forgot to do something, just explain it to me.

    Future<Position> getCurrentPosition({
        LocationAccuracy accuracy = LocationAccuracy.best,
        GeolocationPermission geolocationPermission =
            GeolocationPermission.location,
      }) =>
          _geolocator.getCurrentPosition(
            desiredAccuracy: accuracy,
            locationPermissionLevel: geolocationPermission,
          );
    

    Podfile:

    config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
            '$(inherited)',
    
            ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
             'PERMISSION_LOCATION=1',
          ]
    

    Info.plist:

    	<key>NSLocationWhenInUseUsageDescription</key>
    	<string>Need location when in use</string>
    	<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    	<string>Always and when in use!</string>
    	<key>NSLocationUsageDescription</key>
    	<string>Older devices need location.</string>
    	<key>NSLocationAlwaysUsageDescription</key>
    	<string>Can I haz location always?</string>
    

    EDIT:

    I've tested on a real Android device and the problem is happening too.

    My manifest location permissions:

        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    

    Expected behavior

    Return a Position.

    Reproduction steps

    Just call geolocator.GetCurrentPosition.

    Version: 5.1.5.

    Platform:

    • [x] :iphone: iOS (Tested with IOS Simulator)
    • [x] :robot: Android (Tested on a Xiomi Pocophone F1 with Android 10QkQ1.190828.002)
    platform: ios platform: android status: triage 
    opened by brenoasm 63
  • Android Pie (API 28) Geolocator().getCurrentPosition() does not return

    Android Pie (API 28) Geolocator().getCurrentPosition() does not return

    πŸ› Bug Report

    When I run Geolocator().getCurrentPosition() on Android Emulator with Android Pie (API 28) call is not returning at all.

    I run the same code on API 27 location returns fine. I tried to create new emulator, nothing changes.

    Configuration

    Android Emulator with Android Pie (API 28)

    Version: 2.1.0

    Platform:

    • [ ] :iphone: iOS
    • [X ] :robot: Android
    platform: android 
    opened by savjolovs 39
  • Allow only while using the app in android 10 returns GeolocationStatus.denied

    Allow only while using the app in android 10 returns GeolocationStatus.denied

    πŸ› Bug Report

    when selecting Allow only while using the app the new option in Android 10 Geolocator().checkGeolocationPermissionStatus() returns GeolocationStatus.denied Screenshot_1570103723

    Version: 5.1.4

    Platform: :robot: Android

    platform: android status: in progress 
    opened by humazed 37
  • Get user location through browser

    Get user location through browser

    Hi, I was wondering if this plugins allowed to get the user's location through the browser? I did not find any informations about it ? Is there another plugins who allows it? Thanks in advance for the help !

    type: enhancement platform: web 
    opened by lionelquirynen 32
  • Possibility to access location only in  foreground

    Possibility to access location only in foreground

    πŸš€ Feature Requests

    Good morning everyone! Google has updated Permissions & Location Permissions policies applications must comply with to be published on Google Play.

    The new policy restricts the possibility to access users' location in the background: it would be great to have the possibility to access the location in the foreground only.

    In particular, it is now necessary to request the ACCESS_BACKGROUND_LOCATION permission in the manifest, and to follow the guidelines provided here.

    In case the application is not compliant with the new policy, updates are rejected with error messages similar to this one Background location access not declared We detected that your app contains at least one feature that requests background location access, however you have not submitted a permission declaration form for this feature. Please log in to your Play Console and submit a declaration form.

    Contextualize the feature

    There should exist two new functionalities, which could be implemented either by means of new functions or by adding parameters to the existing ones:

    1. Request foreground location only
    2. Access foreground location, if available, and raise an exception else.

    Describe the feature

    With the proposed modification, the framework should access users' location only when the application is active, without performing any kind of activity when the app is put in background or turned off.

    Platforms affected (mark all that apply)

    • [ ] :iphone: iOS
    • [x] :robot: Android
    status: needs more info platform: android 
    opened by fbambusi 28
  • geolocator_apple-1.2.0 uses methods not available on macOS

    geolocator_apple-1.2.0 uses methods not available on macOS

    Working on an app that should be deployable on Android, iOS and macOS. Using geolocator 7.6.1, building for macOS fails with this error:

    Command CompileSwift failed with a nonzero exit code
    /Users/user/Library/flutter/.pub-cache/hosted/pub.dartlang.org/geolocator_apple-1.2.0/macos/Classes/Handlers/PermissionHandler.m:52:29: error: 'requestWhenInUseAuthorization' is unavailable: not available on macOS
          [self.locationManager requestWhenInUseAuthorization];
                                ^
    In module 'CoreLocation' imported from /Users/user/Library/flutter/.pub-cache/hosted/pub.dartlang.org/geolocator_apple-1.2.0/macos/Classes/Handlers/PermissionHandler.h:11:
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h:406:1: note: 'requestWhenInUseAuthorization' has been explicitly marked unavailable here
    - (void)requestWhenInUseAuthorization API_AVAILABLE(ios(8.0)) API_UNAVAILABLE(macos);
    

    Flutter, Cocoapods, Xcode are all up to date on a machine running Catalina(10.15.7). Flutter doctor reports no issues. Posting this as a question since I'm not sure if this can be an error on my side or if there's a bug in geolocator_apple... any help appreciated!

    platform: macos 
    opened by michpohl 27
  • java.lang.IllegalArgumentException: Service not registered

    java.lang.IllegalArgumentException: Service not registered

    πŸ”™ Regression

    After upgrading to 6.0.0+1 I started to receive an exception as a warning on console multiple times

    Old (and correct) behavior

    Not having an exception

    Reproduction steps

    Just ask the position and the error appears after a while

    Configuration

    Version: 6.0.0+1

    Platform:

    • [ ] :iphone: iOS
    • [X] :robot: Android

    Console output

    W/ConnectionTracker( 1662): Exception thrown while unbinding
    W/ConnectionTracker( 1662): java.lang.IllegalArgumentException: Service not registered: com.google.android.gms.measurement.internal.zzjf@5516abb
    W/ConnectionTracker( 1662):     at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1870)
    W/ConnectionTracker( 1662):     at android.app.ContextImpl.unbindService(ContextImpl.java:1847)
    W/ConnectionTracker( 1662):     at android.content.ContextWrapper.unbindService(ContextWrapper.java:755)
    W/ConnectionTracker( 1662):     at com.google.android.gms.common.stats.ConnectionTracker.zza(com.google.android.gms:play-services-basement@@17.3.0:55)
    W/ConnectionTracker( 1662):     at com.google.android.gms.common.stats.ConnectionTracker.unbindService(com.google.android.gms:play-services-basement@@17.3.0:50)
    W/ConnectionTracker( 1662):     at com.google.android.gms.measurement.internal.zzin.zzah(com.google.android.gms:play-services-measurement-impl@@17.4.1:246)
    W/ConnectionTracker( 1662):     at com.google.android.gms.measurement.internal.zzin.zzam(com.google.android.gms:play-services-measurement-impl@@17.4.1:263)
    W/ConnectionTracker( 1662):     at com.google.android.gms.measurement.internal.zzin.zzc(com.google.android.gms:play-services-measurement-impl@@17.4.1:330)
    W/ConnectionTracker( 1662):     at com.google.android.gms.measurement.internal.zziq.zza(com.google.android.gms:play-services-measurement-impl@@17.4.1:2)
    W/ConnectionTracker( 1662):     at com.google.android.gms.measurement.internal.zzah.run(com.google.android.gms:play-services-measurement-impl@@17.4.1:7)
    W/ConnectionTracker( 1662):     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
    W/ConnectionTracker( 1662):     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    W/ConnectionTracker( 1662):     at com.google.android.gms.measurement.internal.zzfy.run(com.google.android.gms:play-services-measurement-impl@@17.4.1:21)
    
    type: bug platform: android status: in progress 
    opened by inceptusp 25
  • got `LocationServiceDisabledException` when `Geolocator.isLocationServiceEnabled() return true

    got `LocationServiceDisabledException` when `Geolocator.isLocationServiceEnabled() return true

    πŸ› Bug Report

    Expected behavior

    try to get the current location after location permission is granted, and the location service is enabled too, but i got LocationServiceDisabledException when getCurrentPosition is called

    Reproduction steps

    try {
          final enabled = await Geolocator.isLocationServiceEnabled();
    
          print("enabled $enabled"); // true
    
          final permission = await Geolocator.checkPermission();
    
          print("permission $permission"); // whileInUse
     
          final position = await Geolocator.getCurrentPosition(
            desiredAccuracy: LocationAccuracy.medium,
          ); // throw exception here
    
        } catch (e) {
            // i got `LocationServiceDisabledException` here
        }
    

    Configuration

    all permissions related are granted, and all configurations in Android are done.

    Version: 6.1.5

    Platform:

    • [ ] :iphone: iOS
    • [x] :robot: Android
    platform: android status: triage 
    opened by Ralph-Li 24
  • GRPC failed error during various method calls

    GRPC failed error during various method calls

    πŸ› Bug Report

    Hello, we sometimes run to the following problem using Geolocator. Method that throws error varies. This time, we managed to get some information during placemarkFromCoordinates call.


    Error object


    Error type: PlatformException Error message: PlatformException(ERROR_GEOCODING_COORDINATES, grpc failed, null)


    Device info:


    Internet: wifi version.securityPatch: 2018-12-01 version.sdkInt: 27 version.release: 8.1.0 version.previewSdkInt: 0 version.incremental: G390FXXU3BRL3 version.codename: REL version.baseOS: board: universal7570 bootloader: G390FXXU3BRL3 brand: samsung device: xcover4lte display: M1AJQ.G390FXXU3BRL3 hardware: samsungexynos7570 host: SWDH7002 id: M1AJQ manufacturer: samsung model: SM-G390F product: xcover4ltexx supported32BitAbis: [armeabi-v7a, armeabi] supported64BitAbis: [] supportedAbis: [armeabi-v7a, armeabi] tags: release-keys type: user isPhysicalDevice: true


    Permission info:


    calendar: unknown camera: granted contacts: unknown location: granted microphone: granted phone: granted photos: granted reminders: granted sensors: unknown sms: unknown storage: granted speech: granted locationAlways: granted locationWhenInUse: granted mediaLibrary: granted


    Memory info:

    Total physical memory: 1839 MB Free physical memory: 35 MB Total virtual memory: 3375 MB Free virtual memory: 1184 MB

    StackTrace

    #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551)
    #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:292)
    <asynchronous suspension>
    #2      Geolocator.placemarkFromCoordinates (package:geolocator/geolocator.dart:251)
    <asynchronous suspension>
    

    Additional googling of error message showed this SO question pointing to two google bug reports (64418751, 64247769). Looks like there is problem with internal geolocation routines.

    Expected behavior

    Although this problem is caused by another problem in underlying structure, geolocator should not crash but should either

    • throw own specific exception that could be handled in consuming code as PlatformException is pretty general
    • or return null

    Great alternative would be optional possibility to use Geocoding API web service

    Reproduction steps

    There is no clear reproduction manual. Only way we can experience it is by daily use of plugin. Sometimes it happens sometimes not.

    Configuration

    Version: 3.0.1

    Platform:

    • [ ] :iphone: iOS
    • [x] :robot: Android
    type: documentation status: triage status: in progress 
    opened by MartinHlavna 23
  • `Position.heading` is mis-named

    `Position.heading` is mis-named

    πŸ› Bug Report

    The property heading of Position is mis-named. It is actually the course, which can be seen clearly on this line of LocationMapper.m for iOS.

    This is rather unfortunate, as heading and course are distinct concepts, and having it mis-named is confusing:

    In navigation, the course of a watercraft or aircraft is the cardinal direction in which the craft is to be steered. The course is to be distinguished from the heading, which is the direction where the watercraft's bow or the aircraft's nose is pointed.

    In the context of a device, "heading" refers to the direction the device is pointing and is typically provided via a magnetometer. However, "course" refers to the direction the device is traveling and is typically provided via GPS.

    Expected behavior

    A course should be called "course."

    Reproduction steps

    None necessary.

    Configuration

    Version: 1.x

    Platform:

    • [x] :iphone: iOS
    • [ ] :robot: Android
    opened by cbatson 0
  • Getting error Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0).

    Getting error Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0).

    Yesterday I run my code and didn't get any error but just so sudden... (I didn't edit my code) I got an error log like this

    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Could not determine the dependencies of task ':app:lintVitalRelease'.
    > Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
       > Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0).
         Required by:
             project :app
          > Skipped due to earlier error
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 1m 8s
    

    I have tried by running it using another internet connection and still I get the same result. Is there a way to solve this (this error only happen when I run it using android and run so well in ios simulator) I also open this question on https://stackoverflow.com/questions/74895832/how-to-solve-could-not-resolve-com-google-android-gmsplay-services-location15

    opened by wahyu-handayani 0
  • - fixed an issue where the is service location would fail an not repo…

    - fixed an issue where the is service location would fail an not repo…

    Resolves Proposal 1 from the #1183

    :sparkles: What kind of change does this PR introduce? (Bug fix, feature, docs update...)

    It fixes an issue where the location service availability check fails and doesn't report anything.

    :arrow_heading_down: What is the current behavior?

    Nothing, the check just hangs.

    :new: What is the new behavior (if this is a feature change)?

    The check returns an error if it fails.

    :boom: Does this PR introduce a breaking change?

    No.

    :bug: Recommendations for testing

    Install an app on a work profile part of the Android device, and disable the location for the work profile part, and it will be reproducible.

    :memo: Links to relevant issues/docs

    #1183

    :thinking: Checklist before submitting

    • [x] I made sure all projects build.
    • [ ] I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
    • [ ] I updated CHANGELOG.md to add a description of the change.
    • [x] I followed the style guide lines (code style guide).
    • [x] I updated the relevant documentation.
    • [x] I rebased onto current master.
    opened by vlazdra 1
  • Android location service availability improvement for work profile

    Android location service availability improvement for work profile

    πŸ— Enhancement Proposal

    The problem I came across has to do with the location service availability check not working correctly when the app is installed via work profile on an Android device. The reason being is that the code never actually resolves that scenario correctly, it's missing an else statement for the check.

    I've managed to make it work, per say, but I think it can be improved even further by enabling the plugin to actually popup the dialog for enabling the location service.

    Pitch

    Not sure about the contributors part, but will improve the quality of the plugin, and will patch one issue at leat.

    Platforms affected (mark all that apply)

    • [ ] :iphone: iOS
    • [x] :robot: Android

    Proposal 1 - Adding the else statement

    Right now, if the app is installed via the work profile on the device, the isLocationServiceEnabled is not going to work, if the location service is not turned on for the work profile part.

      @Override
      public void isLocationServiceEnabled(LocationServiceListener listener) {
        LocationServices.getSettingsClient(context)
            .checkLocationSettings(new LocationSettingsRequest.Builder().build())
            .addOnCompleteListener(
                (response) -> {
                  if (response.isSuccessful()) {
                    LocationSettingsResponse lsr = response.getResult();
                    if (lsr != null) {
                      LocationSettingsStates settingsStates = lsr.getLocationSettingsStates();
                      boolean isGpsUsable = settingsStates != null && settingsStates.isGpsUsable();
                      boolean isNetworkUsable =
                          settingsStates != null && settingsStates.isNetworkLocationUsable();
                      listener.onLocationServiceResult(isGpsUsable || isNetworkUsable);
                    } else {
                      listener.onLocationServiceError(ErrorCodes.locationServicesDisabled);
                    }
                  }
                });
      }
    

    It's missing the else statement here, because a call towards the checkLocationSettings is resulting in an unsuccessful call. So by just adding the else statement, you can cover the use case where the app is installed via work profile and the service is not enabled, like so:

    
    if (response.isSuccessful()) {
       // ...
    } else {
        listener.onLocationServiceError(ErrorCodes.locationServicesDisabled);
    }
    

    Proposal 2 - Asking the user to enable location

    There is a way to ask the user to enable the location, it applies for either the work profile or the regular personal profile. In order to ask the user to enable the location service for the specific profile, you would need call startResolutionForResult((Activity) context, 123);

    Now with this call, the entire request would look something like this:

     @Override
        public void isLocationServiceEnabled(LocationServiceListener listener) {
            LocationServices.getSettingsClient(context)
                    .checkLocationSettings(new LocationSettingsRequest.Builder().build())
                    .addOnCompleteListener(
                            (response) -> {
                                if (response.isSuccessful()) {
                                   // ...
                                } else {
                                    if (response.getException() instanceof ResolvableApiException) {
                                        final ResolvableApiException exception = (ResolvableApiException) response.getException();
    
                                        switch (exception.getStatusCode()) {
                                            case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
                                                // Location settings are not satisfied. But could be fixed by showing the
                                                // user a dialog.
                                                try {
                                                    // Cast to a resolvable exception.
                                                    // Show the dialog by calling startResolutionForResult(),
                                                    // and check the result in onActivityResult().
                                                    exception.startResolutionForResult((Activity) context, 123123);
                                                    listener.onLocationServiceError(ErrorCodes.error0);
                                                } catch (IntentSender.SendIntentException e) {
                                                    // Ignore the error.
                                                    listener.onLocationServiceError(ErrorCodes.error1);
                                                } catch (ClassCastException e) {
                                                    // Ignore, should be an impossible error.
                                                    listener.onLocationServiceError(ErrorCodes.error2);
                                                }
                                                break;
                                            case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
                                                // Location settings are not satisfied. However, we have no way to fix the
                                                // settings so we won't show the dialog.
                                                listener.onLocationServiceError(ErrorCodes.error3);
                                                break;
                                        }
                                    }
                                }
                            });
        }
    

    Source of the code example above is from Google Play Services - Settings Client docs The example above would trigger a popup that would ask the user to turn on the service. It will look something like this: Location popup

    Now there is a catch with this one, it depends on the onActivityResult, where it actually reports the result of the request if the user allowed or disallowed the location service. And in order for it to work, the end developer would need to implement it in their MainActivity (I'm not aware that a plugin can register that kind of a callback).

    It took me some time to investigate this one fully (I might have missed something), to better understand why the location check was failing if the app was installed via the work profile where the location was turned off. And I'm still digesting all of the things I uncover, so if you have any questions, please feel free to ask, I will do my best to answer them if I can.

    opened by vlazdra 0
  • How to close runtime permission dialog programmatically?

    How to close runtime permission dialog programmatically?

    πŸ’¬ Questions and Help

    I want to close runtime permission dialog with deny as selected option when user sends the app to background. How can I handle this? Thanks in advance.

    opened by shahpasandar 0
Owner
Baseflow
We provide software, skills and knowledge and with this we want to make a contribution to the world. We love to make innovation happen.
Baseflow
Android and iOS Geolocation plugin for Flutter

Flutter geolocator plugin The Flutter geolocator plugin is build following the federated plugin architecture. A detailed explanation of the federated

Baseflow 891 Nov 14, 2021
Android and iOS Geolocation plugin for Flutter

Flutter geolocator plugin The Flutter geolocator plugin is build following the federated plugin architecture. A detailed explanation of the federated

Baseflow 1k Dec 27, 2022
Aplications with google maps and geolocation

Aplications with google maps and geolocation

Richardson Tsavo 4 Jul 26, 2022
ParkPort is a smartphone application that utilizes geolocation to guide the user to explore Tulsa's parks and collect augmented reality stamps.

A smartphone application that utilizes geolocation to guide the user to explore Tulsa's parks and collect augmented reality stamps.

Adam Taylor 5 Dec 20, 2022
Wrapper around ip-geolocation.io api

wrapper around ip-geolocation.io api

cedvdb 1 Nov 18, 2021
A Flutter example to use Google Maps in iOS and Android apps via the embedded Google Maps plugin Google Maps Plugin

maps_demo A Flutter example to use Google Maps in iOS and Android apps via the embedded Google Maps plugin Google Maps Plugin Getting Started Get an A

Gerry High 41 Feb 14, 2022
A Flutter plugin to easily handle realtime location in iOS and Android. Provides settings for optimizing performance or battery.

Flutter Location Plugin This plugin for Flutter handles getting a location on Android and iOS. It also provides callbacks when the location is changed

Guillaume Bernos 953 Dec 22, 2022
A Flutter plugin for integrating Google Maps in iOS, Android and Web applications

flutter_google_maps A Flutter plugin for integrating Google Maps in iOS, Android and Web applications. It is a wrapper of google_maps_flutter for Mobi

MarchDev Toolkit 86 Sep 26, 2022
A Flutter package for iOS and Android for picking location and images.

location and image picker package for Flutter A Flutter package for iOS and Android for picking location and images. Demo Installation First, add loca

sk shamimul islam 9 Sep 28, 2022
Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL

Mapbox GL Native A C++ library that powers customizable vector maps in native applications on multiple platforms by taking stylesheets that conform to

Mapbox 4.2k Jan 6, 2023
A Flutter package to provide the native maps to Android/iOS

platform_maps_flutter A Flutter package that provides a native map to both Android and iOS devices. The plugin relies on Flutter's mechanism for embed

Luis Thein 70 Aug 13, 2022
A migration of Google Maps Application with Flutter & Google Maps APIs including: Maps SDK for Android & IOS, Places API & polylines

google_maps A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

TAD 1 Mar 4, 2022
An Android/iOS app that calculates tips/splits

tipsy An Android/iOS App that calculates Tips/Splits. Getting Started This project is a starting point for a Flutter application. A few resources to g

Srujan Joshi 1 Dec 4, 2021
flutter_map plugin to request and display the users location and heading on the map

The plugin is discontinued. Feel free to fork it or checkout similar plugins. Flutter Map – Location plugin A flutter_map plugin to request and displa

Fabian Rosenthal 19 Oct 11, 2022
Flutter plugin for forward and reverse geocoding

geocoder Forward and reverse geocoding. Usage Import package:geocoder/geocoder.dart, and use the Geocoder.local to access geocoding services provided

AloΓ―s Deniel 177 Dec 31, 2022
A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

Boris Gautier 5 Sep 14, 2022
A flutter plugin for Google Maps

IMPORTANT: This plugin is no longer under development Why? We initially built this plugin to fill an early gap in flutter. Since then, Google has made

AppTree Software, Inc 415 Dec 29, 2022
Flutter plugin to display a simple flat world map with animated points in real time

Flutter Simple Map Flutter plugin to display a simple flat world map with animated points in real time. Can be used as a presentation of online users,

Vladyslav Korniienko 7 Dec 8, 2022
Apple Maps Plugin for Flutter

apple_maps_flutter A Flutter plugin that provides an Apple Maps widget. The plugin relies on Flutter's mechanism for embedding Android and iOS views.

Luis Thein 50 Dec 31, 2022