Flutter geolocation plugin for Android and iOS.

Overview

geolocation

pub package

Flutter geolocation plugin for Android API 16+ and iOS 9+.

Features:

  • Manual and automatic location permission management
  • Current one-shot location
  • Continuous location updates with foreground and background options

The plugin is under active development and the following features are planned soon:

  • Geocode
  • Geofences
  • Place suggestions
  • Activity recognition
  • Exposition of iOS/Android specific APIs (like significant location updates on iOS)
Android iOS

Installation

Follow the instructions: https://pub.dev/packages/geolocation#-installing-tab-

iOS

Objective-C compatibility

For Flutter projects created with the Objective-C template, you might need to add use_frameworks! at the top of ios/Podfile. More details can be found in the following issue: https://github.com/flutter/flutter/issues/16049#issuecomment-552060349

Android

AndroidX

Geolocation is dependent on AndroidX. Make sure to include the following settings to 'android/gradle.properties':

android.useAndroidX=true
android.enableJetifier=true
R8/Proguard code obfuscation

If you have enabled code obfuscation with R8 or proguard, you need to add the following rules.

android/app/build.gradle:

buildTypes {
  release {
    minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  }
}

android/app/proguard-rules.pro:

# Geolocation - start

-keep class app.loup.geolocation.** { *; }

    # Moshi - start
    # https://github.com/square/moshi/blob/master/moshi/src/main/resources/META-INF/proguard/moshi.pro

    # JSR 305 annotations are for embedding nullability information.
    -dontwarn javax.annotation.**

    -keepclasseswithmembers class * {
        @com.squareup.moshi.* <methods>;
    }

    -keep @com.squareup.moshi.JsonQualifier interface *

    # Enum field names are used by the integrated EnumJsonAdapter.
    # values() is synthesized by the Kotlin compiler and is used by EnumJsonAdapter indirectly
    # Annotate enums with @JsonClass(generateAdapter = false) to use them with Moshi.
    -keepclassmembers @com.squareup.moshi.JsonClass class * extends java.lang.Enum {
        <fields>;
        **[] values();
    }

    # Moshi - end

# Geolocation - end

Permission

Android and iOS require to declare the location permission in a configuration file.

For iOS

There are two kinds of location permission available in iOS: "when in use" and "always".

If you don't know what permission to choose for your usage, see: https://developer.apple.com/documentation/corelocation/choosing_the_authorization_level_for_location_services

You need to declare the description for the desired permission in ios/Runner/Info.plist:

<dict>
  <!-- for iOS 11 + -->
  <key>NSLocationWhenInUseUsageDescription</key>
  <string>Reason why app needs location</string>
  <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
  <string>Reason why app needs location</string>

  <!-- additionally for iOS 9/10, if you need always permission -->
  <key>NSLocationAlwaysUsageDescription</key>
  <string>Reason why app needs location</string>
  ...
</dict>

For Android

There are two kinds of location permission in Android: "coarse" and "fine". Coarse location will allow to get approximate location based on sensors like the Wifi, while fine location returns the most accurate location using GPS (in addition to coarse).

You need to declare one of the two permissions in android/app/src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <!-- or -->
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

Note that ACCESS_FINE_LOCATION permission includes ACCESS_COARSE_LOCATION.

API

For more complete documentation on all usage, check the API documentation:
https://pub.dartlang.org/documentation/geolocation/latest/geolocation/geolocation-library.html

You can also check the example project that showcase a comprehensive usage of Geolocation plugin.

Check if location service is operational

API documentation: https://pub.dartlang.org/documentation/geolocation/latest/geolocation/Geolocation/isLocationOperational.html

final GeolocationResult result = await Geolocation.isLocationOperational();
if(result.isSuccessful) {
  // location service is enabled, and location permission is granted
} else {
  // location service is not enabled, restricted, or location permission is denied
}

Request location permission

On Android (api 23+) and iOS, apps need to request location permission at runtime.

Note: You are not required to request permission manually. Geolocation plugin will request permission automatically if it's needed, when you make a location request.

API documentation: https://pub.dartlang.org/documentation/geolocation/latest/geolocation/Geolocation/requestLocationPermission.html

final GeolocationResult result = await Geolocation.requestLocationPermission(
  const LocationPermission(
    android: LocationPermissionAndroid.fine,
    ios: LocationPermissionIOS.always,
  ),
  openSettingsIfDenied: true,
);

if(result.isSuccessful) {
  // location permission is granted (or was already granted before making the request)
} else {
  // location permission is not granted
  // user might have denied, but it's also possible that location service is not enabled, restricted, and user never saw the permission request dialog. Check the result.error.type for details.
}

Get the current one-shot location

Geolocation offers three methods:

// get last known location, which is a future rather than a stream (best for android)
LocationResult result = await Geolocation.lastKnownLocation();

// force a single location update (best for ios)
StreamSubscription<LocationResult> subscription = Geolocation.currentLocation(accuracy: LocationAccuracy.best).listen((result) {
  // todo with result
});

// best option for most cases
StreamSubscription<LocationResult> subscription = Geolocation.currentLocation(accuracy: LocationAccuracy.best).listen((result) {
  if(result.isSuccessful) {
    Double latitude = result.location.latitude;
    // todo with result
  }
});

Continuous location updates

API documentation: https://pub.dartlang.org/documentation/geolocation/latest/geolocation/Geolocation/locationUpdates.html

StreamSubscription<LocationResult> subscription = Geolocation.locationUpdates(
    accuracy: LocationAccuracy.best,
    displacementFilter: 10.0, // in meters
    inBackground: true, // by default, location updates will pause when app is inactive (in background). Set to `true` to continue updates in background.
  )
  .listen((result) {
    if(result.isSuccessful) {
      // todo with result
    }
  });


// cancelling subscription will also stop the ongoing location request
subscription.cancel();

Handle location result

Location request return either a LocationResult future or a stream of LocationResult.

API documentation: https://pub.dartlang.org/documentation/geolocation/latest/geolocation/LocationResult-class.html

LocationResult result = await Geolocation.lastKnownLocation();

if (result.isSuccessful) {
  // location request successful, location is guaranteed to not be null
  double lat = result.location.latitude;
  double lng = result.location.longitude;
} else {
  switch (result.error.type) {
    case GeolocationResultErrorType.runtime:
      // runtime error, check result.error.message
      break;
    case GeolocationResultErrorType.locationNotFound:
      // location request did not return any result
      break;
    case GeolocationResultErrorType.serviceDisabled:
      // location services disabled on device
      // might be that GPS is turned off, or parental control (android)
      break;
    case GeolocationResultErrorType.permissionNotGranted:
      // location has not been requested yet
      // app must request permission in order to access the location
      break;
    case GeolocationResultErrorType.permissionDenied:
      // user denied the location permission for the app
      // rejection is final on iOS, and can be on Android if user checks `don't ask again`
      // user will need to manually allow the app from the settings, see requestLocationPermission(openSettingsIfDenied: true)
      break;
    case GeolocationResultErrorType.playServicesUnavailable:
      // android only
      // result.error.additionalInfo contains more details on the play services error
      switch(result.error.additionalInfo as GeolocationAndroidPlayServices) {
        // do something, like showing a dialog inviting the user to install/update play services
        case GeolocationAndroidPlayServices.missing:
        case GeolocationAndroidPlayServices.updating:
        case GeolocationAndroidPlayServices.versionUpdateRequired:
        case GeolocationAndroidPlayServices.disabled:
        case GeolocationAndroidPlayServices.invalid:
      }
    break;
  }
}

Authors

Geolocation plugin is developed by Loup, a mobile development studio based in Montreal and Paris.
You can contact us at [email protected]

Contributers

  • lukaspili
  • mit-mit
  • shehabic-work
  • Abgaryan
  • shehabic
  • alfanhui

License

Apache License 2.0

Comments
  • Dart SDK version (2.1.0) is not supported by geolocation

    Dart SDK version (2.1.0) is not supported by geolocation

    From @markflarup on September 5, 2018 8:35

    URL: https://pub.dartlang.org/packages/geolocation#-installing-tab-

    I want to support geo location in an app, but after adding geolocation: ^0.2.1 as a dependency the following error message is returned:

    The current Dart SDK version is 2.1.0-dev.0.0.flutter-be6309690f.
    
    Because [APP] depends on geolocation >=0.1.1 which requires SDK version <2.0.0, version solving failed.
    pub get failed (1)
    

    Do you have a estimate for when it will be supported?

    Copied from original issue: dart-lang/pub-dartlang-dart#1580

    opened by isoos 11
  • Pubspec doesn't declare compatibility with Dart 2

    Pubspec doesn't declare compatibility with Dart 2

    The Dart SDK constraints need to be updated to declare compatibility with Dart 2 stable.

    It looks like this was fixed in https://github.com/loup-v/geolocation/commit/f32b900ec98f5251d30ebb189e0772863217863e#diff-fb2d52cd953afedcafc9fe7629c6f132, but never published?

    opened by mit-mit 10
  • Podfile error on iOS device.

    Podfile error on iOS device.

    Thanks for the plugin. I am trying to use it in my app and when I use it and run my app on an iPhone 7 iOS 11.2.5 it throws the following error while running the pod install: Automatically assigning platform `ios` with version `8.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile.

    opened by Samaritan1011001 7
  • Android App crashes

    Android App crashes

    E/AndroidRuntime( 9484): java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode E/AndroidRuntime( 9484): at android.support.v4.app.BaseFragmentActivityApi14.checkForValidRequestCode(BaseFragmentActivityApi14.java:79) E/AndroidRuntime( 9484): at android.support.v4.app.FragmentActivity.validateRequestPermissionsRequestCode(FragmentActivity.java:765) E/AndroidRuntime( 9484): at android.support.v4.app.ActivityCompat.requestPermissions(ActivityCompat.java:505) E/AndroidRuntime( 9484): at io.intheloup.geolocation.location.LocationClient.requestPermission(LocationClient.kt:288) E/AndroidRuntime( 9484): at io.intheloup.geolocation.location.LocationClient.validateServiceStatus(LocationClient.kt:245) E/AndroidRuntime( 9484): at io.intheloup.geolocation.location.LocationClient.requestLocationPermission(LocationClient.kt:71) E/AndroidRuntime( 9484): at io.intheloup.geolocation.LocationChannel$requestLocationPermission$1.doResume(LocationChannel.kt:31) E/AndroidRuntime( 9484): at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:54) E/AndroidRuntime( 9484): at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:161) E/AndroidRuntime( 9484): at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:25) E/AndroidRuntime( 9484): at android.os.Handler.handleCallback(Handler.java:739) E/AndroidRuntime( 9484): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime( 9484): at android.os.Looper.loop(Looper.java:158) E/AndroidRuntime( 9484): at android.app.ActivityThread.main(ActivityThread.java:7229) E/AndroidRuntime( 9484): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 9484): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) E/AndroidRuntime( 9484): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

    bug 
    opened by Abgaryan 5
  • App Crashing after integrating geolocation

    App Crashing after integrating geolocation

    I'm experiencing and issue where my app can no longer launch after integrating the geolocation plugin.

    I'm seeing the following error:

    04-20 10:38:07.162 28097-28097/greensensor.com.greensensor E/AndroidRuntime: FATAL EXCEPTION: main Process: greensensor.com.greensensor, PID: 28097 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/Api$zzf; at com.google.android.gms.location.LocationServices.(Unknown Source:0) at com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(Unknown Source:0) at io.intheloup.geolocation.location.LocationClient.(LocationClient.kt:40) at io.intheloup.geolocation.GeolocationPlugin.(GeolocationPlugin.kt:14) at io.intheloup.geolocation.GeolocationPlugin$Companion.registerWith(GeolocationPlugin.kt:57) at io.intheloup.geolocation.GeolocationPlugin.registerWith(Unknown Source:2) at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:29) at greensensor.com.greensensor.MainActivity.onCreate(MainActivity.java:12) at android.app.Activity.performCreate(Activity.java:6975) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.api.Api$zzf" on path: DexPathList[[zip file "/data/app/greensensor.com.greensensor-GIph4HLdX8jz_m5c7vM3jQ==/base.apk"],nativeLibraryDirectories=[/data/app/greensensor.com.greensensor-GIph4HLdX8jz_m5c7vM3jQ==/lib/arm64, /system/fake-libs64, /data/app/greensensor.com.greensensor-GIph4HLdX8jz_m5c7vM3jQ==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) ... ...

    considering the Dex comment in that log, i'm suspecting a Play Services versioning issue, but i'm not sure how to fix that

    opened by mortenboye 5
  • Android - currentLocation won't update location

    Android - currentLocation won't update location

    calling currentLocation on the android emulator will return the last known location - and if a location is not available (eg if you turned off location and then turned it back on), it will return nothing. It probably should in should try to get the location rather than failing without trying.

    Also - in order to test out different locations I have to go to the maps app after changing the emulator location before currentLocation will pick up on the new location,.

    I tried to use singleLocationUpdate on android but had the same issues. In light of the above, what is your advice If I want a single updated location.

    opened by urbandove 5
  • Dependency conflict with firebase plugins on `play-services-base`

    Dependency conflict with firebase plugins on `play-services-base`

    Current firebase plugins depend on 11.8.0 while geolocation on 12.0.1. Don't know what the resolution is and not a big mobile developer. Tips how this could be resolved?

    enhancement 
    opened by daniel-v 5
  • No static method '_fromJson' declared in class 'LocationResult'

    No static method '_fromJson' declared in class 'LocationResult'

    I was testing this plugin. I ran this code

    import 'package:geolocation/geolocation.dart';
    
    find() async {
        LocationResult result = await Geolocation.currentLocation(LocationAccuracy.best);
    }
    

    I got this error

    [VERBOSE-2:dart_error.cc(16)] Unhandled exception:
    NoSuchMethodError: No static method '_fromJson' declared in class 'LocationResult'.
    Receiver: LocationResult
    Tried calling: _fromJson(_LinkedHashMap len:2)
    #0      NoSuchMethodError._throwNew (dart:core-patch/dart:core/errors_patch.dart:192)
    #1      _Codec.decodeLocation (package:geolocation/channel/codec.dart:8:22)
    #2      _Api.currentLocation (package:geolocation/channel/api.dart:20:19)
    <asynchronous suspension>
    #3      Geolocation.currentLocation (package:geolocation/geolocation.dart:52:12)
    <asynchronous suspension>
    #4      UserLocation.find (/Users/gorjan/Projects/aero/lib/models/UserLocation.dart:18:47)
    <asynchronous suspension>
    #5      HomeState.initState (/Users/gorjan/Projects/aero/lib/pages/home.dart:26:26)
    #6      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3734:58)
    #7      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
    #8      Element.inflateWidget (package:flutter/src/widgets/framework
    

    Testing on iPhone X iOS 11.3

    Pubspec

     geolocation: "0.1.1"
    
    bug 
    opened by gorjan-mishevski 5
  • Republished package [new_geolocation]

    Republished package [new_geolocation]

    I have republished this packaged aptly named: new_geolocation

    I have included most of the items in PR as of today.

    Feel free to submit new PRs into my forkfor review.

    opened by alfanhui 4
  • geolocation not building in iOS

    geolocation not building in iOS

    === BUILD TARGET uni_links OF PROJECT Pods WITH CONFIGURATION Release === /.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.1.6/ios/Classes/FlutterWebviewPlugin.m:59:22: warning: incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'id _Nullable' [-Wint-conversion] _enableAppScheme = call.arguments[@"enableAppScheme"]; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.1.6/ios/Classes/FlutterWebviewPlugin.m:188:78: warning: values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead [-Wformat] id data = [FlutterError errorWithCode:[NSString stringWithFormat:@"%ld", error.code] ~~~ ^~~~~~~~~~ %ld (long) 2 warnings generated. /.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/ios/Classes/GeolocationPlugin.m:7:9: fatal error: 'geolocation/geolocation-Swift.h' file not found #import <geolocation/geolocation-Swift.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. /.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/ios/Classes/GeolocationPlugin.m:7:9: fatal error: 'geolocation/geolocation-Swift.h' file not found #import <geolocation/geolocation-Swift.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:27:31: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability] - (void)safariViewController:(SFSafariViewController *)controller ^ In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here @interface SFSafariViewController : UIViewController ^ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:27:1: note: annotate 'safariViewController:didCompleteInitialLoad:' with an availability attribute to silence this warning - (void)safariViewController:(SFSafariViewController *)controller ^ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:43:40: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability] - (void)safariViewControllerDidFinish:(SFSafariViewController *)controller { ^ In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here @interface SFSafariViewController : UIViewController ^ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:43:1: note: annotate 'safariViewControllerDidFinish:' with an availability attribute to silence this warning - (void)safariViewControllerDidFinish:(SFSafariViewController *)controller { ^ API_AVAILABLE(ios(9.0)) /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:29:31: warning: comparison between pointer and integer ('NSInteger' (aka 'int') and 'void *') if (_previousStatusBarStyle != nil) { ~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:111:45: warning: comparison between pointer and integer ('NSInteger' (aka 'int') and 'void ') if (self->_previousStatusBarStyle != nil) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:108:18: warning: 'openURL:options:completionHandler:' is only available on iOS 10.0 or newer [-Wunguarded-availability] [application openURL:url ^~~~~~~~~~~ In module 'UIKit' imported from /NevesSoftware/ns_giftcard2/loyality/ios/Pods/Target Support Files/url_launcher/url_launcher-prefix.pch:2: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:134:1: note: 'openURL:options:completionHandler:' has been explicitly marked partial here - (void)openURL:(NSURL)url options:(NSDictionary<NSString *, id> *)options completionHandler:(void (^ __nullable)(BOOL success))completion NS_AVAILABLE_IOS(10_0) NS_EXTENSION_UNAVAILABLE_IOS(""); ^ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:108:18: note: enclose 'openURL:options:completionHandler:' in an@available check to silence this warning [application openURL:url ^~~~~~~~~~~ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:3: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability] SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url]; ^~~~~~~~~~~~~~~~~~~~~~ In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here @interface SFSafariViewController : UIViewController ^ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:3: note: enclose 'SFSafariViewController' in an @available check to silence this warning SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url]; ^~~~~~~~~~~~~~~~~~~~~~ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:38: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability] SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url]; ^~~~~~~~~~~~~~~~~~~~~~ In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here @interface SFSafariViewController : UIViewController ^ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:38: note: enclose 'SFSafariViewController' in an @available check to silence this warning SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url]; ^~~~~~~~~~~~~~~~~~~~~~ 7 warnings generated. /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:27:31: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability] - (void)safariViewController:(SFSafariViewController *)controller ^ In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here @interface SFSafariViewController : UIViewController ^ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:27:1: note: annotate 'safariViewController:didCompleteInitialLoad:' with an availability attribute to silence this warning - (void)safariViewController:(SFSafariViewController *)controller ^ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:43:40: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability] - (void)safariViewControllerDidFinish:(SFSafariViewController *)controller { ^ In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here @interface SFSafariViewController : UIViewController ^ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:43:1: note: annotate 'safariViewControllerDidFinish:' with an availability attribute to silence this warning - (void)safariViewControllerDidFinish:(SFSafariViewController *)controller { ^ API_AVAILABLE(ios(9.0)) /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:29:31: warning: comparison between pointer and integer ('NSInteger' (aka 'long') and 'void *') if (_previousStatusBarStyle != nil) { ~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:111:45: warning: comparison between pointer and integer ('NSInteger' (aka 'long') and 'void ') if (self->_previousStatusBarStyle != nil) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:108:18: warning: 'openURL:options:completionHandler:' is only available on iOS 10.0 or newer [-Wunguarded-availability] [application openURL:url ^~~~~~~~~~~ In module 'UIKit' imported from /NevesSoftware/ns_giftcard2/loyality/ios/Pods/Target Support Files/url_launcher/url_launcher-prefix.pch:2: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:134:1: note: 'openURL:options:completionHandler:' has been explicitly marked partial here - (void)openURL:(NSURL)url options:(NSDictionary<NSString *, id> *)options completionHandler:(void (^ __nullable)(BOOL success))completion NS_AVAILABLE_IOS(10_0) NS_EXTENSION_UNAVAILABLE_IOS(""); ^ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:108:18: note: enclose 'openURL:options:completionHandler:' in an@available check to silence this warning [application openURL:url ^~~~~~~~~~~ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:3: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability] SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url]; ^~~~~~~~~~~~~~~~~~~~~~ In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here @interface SFSafariViewController : UIViewController ^ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:3: note: enclose 'SFSafariViewController' in an @available check to silence this warning SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url]; ^~~~~~~~~~~~~~~~~~~~~~ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:38: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability] SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url]; ^~~~~~~~~~~~~~~~~~~~~~ In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here @interface SFSafariViewController : UIViewController ^ /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:38: note: enclose 'SFSafariViewController' in an @available check to silence this warning SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url]; ^~~~~~~~~~~~~~~~~~~~~~ 7 warnings generated. Encountered error while building for device. philipneves@Philips-MacBook-Pro:~/NevesSoftware/ns_giftcard2/loyality$ flutter run Launching lib/main.dart on Philip Neves’s iPod in debug mode... Automatically signing iOS for device deployment using specified development team in Xcode project: HDUGN2FSU6 Running pod install... 2.0s Starting Xcode build... Xcode build done. 7.9s Failed to build iOS app Error output from Xcode build: ↳ ** BUILD FAILED **

    Xcode's output: ↳ /.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/ios/Classes/GeolocationPlugin.m:7:9: fatal error: 'geolocation/geolocation-Swift.h' file not found #import <geolocation/geolocation-Swift.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. Could not build the precompiled application for the device.

    opened by pneves001 4
  • "Missing location usage description values in Info.plist" even if it isn't the case.

    So I changed my Info.plist file like explained in the README :

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    	<key>NSLocationWhenInUseUsageDescription</key>
    	<string>I need you I need you I need you right now</string>
    	<key>CFBundleDevelopmentRegion</key>
    	<string>en</string>
    	<key>CFBundleExecutable</key>
    	<string>$(EXECUTABLE_NAME)</string>
    	<key>CFBundleIdentifier</key>
    	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    	<key>CFBundleInfoDictionaryVersion</key>
    	<string>6.0</string>
    	<key>CFBundleName</key>
    	<string>tplusg</string>
    	<key>CFBundlePackageType</key>
    	<string>APPL</string>
    	<key>CFBundleShortVersionString</key>
    	<string>1.0</string>
    	<key>CFBundleSignature</key>
    	<string>????</string>
    	<key>CFBundleVersion</key>
    	<string>1</string>
    	<key>LSRequiresIPhoneOS</key>
    	<true/>
    	<key>UILaunchStoryboardName</key>
    	<string>LaunchScreen</string>
    	<key>UIMainStoryboardFile</key>
    	<string>Main</string>
    	<key>UIRequiredDeviceCapabilities</key>
    	<array>
    		<string>arm64</string>
    	</array>
    	<key>UISupportedInterfaceOrientations</key>
    	<array>
    		<string>UIInterfaceOrientationPortrait</string>
    		<string>UIInterfaceOrientationLandscapeLeft</string>
    		<string>UIInterfaceOrientationLandscapeRight</string>
    	</array>
    	<key>UISupportedInterfaceOrientations~ipad</key>
    	<array>
    		<string>UIInterfaceOrientationPortrait</string>
    		<string>UIInterfaceOrientationPortraitUpsideDown</string>
    		<string>UIInterfaceOrientationLandscapeLeft</string>
    		<string>UIInterfaceOrientationLandscapeRight</string>
    	</array>
    	<key>UIViewControllerBasedStatusBarAppearance</key>
    	<false/>
    </dict>
    </plist>
    

    But it throws me this error saying it can't find the location usage description values in Info.plist :

    [VERBOSE-2:dart_error.cc(16)] Unhandled exception:
    Geolocation error: Missing location usage description values in Info.plist. See readme for details.
    #0      _JsonCodec.resultErrorFromJson (file:///Users/gaetan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/lib/channel/codec.dart:70:7)
    #1      _JsonCodec.resultFromJson (file:///Users/gaetan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/lib/channel/codec.dart:47:33)
    #2      _Codec.decodeResult (file:///Users/gaetan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/lib/channel/codec.dart:8:18)
    #3      _LocationChannel.isLocationOperational (file:///Users/gaetan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/lib/channel/location_channel.dart:37:19)
    <asynchronous suspension>
    #4      Geolocation.isLocationOperational (package:geolocation/geolocation.dart:46:24)
    #5      _StopsAroundPageState.checkGPS (file:///Users/gaetan/Developer/tplusg/lib/views/tabs/around.da<…>
    
    

    Am I doing something wrong ?

    more info needed 
    opened by gaetschwartz 4
  • Build error on v1.1.2 java.lang.reflect.InvocationTargetException

    Build error on v1.1.2 java.lang.reflect.InvocationTargetException

    ` FAILURE: Build failed with an exception.

    • What went wrong: Execution failed for task ':geolocation:kaptDebugKotlin'.

    A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction java.lang.reflect.InvocationTargetException (no error message)`

    On Flutter 2.10.3

    I've added all the proguard rules etc.

    opened by irjayjay 1
  • Force new location

    Force new location

    Does this package support a way of asking the OS to force the calculation of a new location ? Getting the last known location is not good enough for me.

    opened by mtc-jed 0
  • Add headless mode ?

    Add headless mode ?

    I'm trying to use register the plugin manually to be able to use it in a background process with background_locator. (I need to get more than one location update in some cases with this plugin's background function)

    It seems that the geolocation plugin cannot be registered headless. See this similar issue : https://github.com/transistorsoft/flutter_background_fetch/issues/12 I'm getting the same error.

    It works with the geolocator plugin but for some reasons the location updates are not working as expected when I use this plugin.

    Could it be possible to add this 'headless registration' feature please ? Thanks !

    opened by ludesert 1
  • Assertion failure in -[CLLocationManager setAllowsBackgroundLocationUpdates:]

    Assertion failure in -[CLLocationManager setAllowsBackgroundLocationUpdates:]

    Android Studio 4 + Flutter pluggin

    MacOS 10.15 - Catalina

    geolocator: ^5.3.2+2

    When I start my Flutter's project on Android device it's run success. And success work with geolocations. Nice.

    But when I start my Flutter project on iphone (9) I get error:

    *** Assertion failure in -[CLLocationManager setAllowsBackgroundLocationUpdates:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/CoreLocationFramework/CoreLocation-1861.3.25.50/Framework/CoreLocation/CLLocationManager.m:609
    Lost connection to device.
    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient)'
    	*** First throw call stack:
    	(0x2276f91b 0x21f0ae17 0x2276f7f1 0x22f53529 0x286c32ed 0x1ed13a1 0x1ed11eb 0x1ed1985 0x1ed0543 0x1ecfe29 0x2a54c5 0x25209b 0x29960d 0x260257 0x261c6b 0x2273258f 0x227321c1 0x2273000d 0x2267f229 0x2267f015 0x23c6fac9 0x26d53189 0xf9edd 0x22327873)
    
    opened by alexei-28 0
Releases(v1.1.2)
Owner
Loup
Loup
Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.

On most operating systems, permissions aren't just granted to apps at install time. Rather, developers have to ask the user for permissions while the

Baseflow 1.7k Jan 3, 2023
Flutter Downloader - A plugin for creating and managing download tasks. Supports iOS and Android. Maintainer: @hnvn

Flutter Downloader A plugin for creating and managing download tasks. Supports iOS and Android. This plugin is based on WorkManager in Android and NSU

Flutter Community 789 Jan 3, 2023
File picker plugin for Flutter, compatible with both iOS & Android and desktop (go-flutter).

File Picker A package that allows you to use the native file explorer to pick single or multiple files, with extensions filtering support. Currently s

Miguel Ruivo 985 Jan 5, 2023
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 location on Android and iOS. It also provides callbacks when location is changed. Gett

Guillaume Bernos 953 Dec 22, 2022
A Flutter plugin for displaying local notifications on Android, iOS and macOS

Flutter Local Notifications plugin This repository consists hosts the following packages flutter_local_notifications: code for the cross-platform faci

Michael Bui 2.1k Dec 30, 2022
Flutter Plugin for AR (Augmented Reality) - Supports ARKit on iOS and ARCore on Android devices

ar_flutter_plugin Flutter Plugin for AR (Augmented Reality) - Supports ARKit for iOS and ARCore for Android devices. Many thanks to Oleksandr Leuschen

Lars Carius 222 Jan 4, 2023
Telegram stickers importing Flutter plugin for iOS and Android

TelegramStickersImport — Telegram stickers importing Flutter plugin for iOS and Android TelegramStickersImport helps your users import third-party pro

Iurii Dorofeev 20 Dec 3, 2022
Plugin to retrieve a persistent UDID across app reinstalls on iOS and Android.

flutter_udid Plugin to retrieve a persistent UDID across app reinstalls on iOS and Android. Getting Started import 'package:flutter_udid/flutter_udid.

Leon Kukuk 183 Dec 21, 2022
Support to update the app badge on the launcher (both for Android and iOS)

Flutter App Badger plugin This plugin for Flutter adds the ability to change the badge of the app in the launcher. It supports iOS and some Android de

Edouard Marquez 258 Dec 25, 2022
A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.

Flutter InAppWebView Plugin A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser windo

Lorenzo Pichilli 2.3k Jan 8, 2023
A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed apps.

Flutter AppAvailability Plugin A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed a

Lorenzo Pichilli 89 Dec 2, 2022
A lightweight Flutter plugin for making payments and printing on MyPos

my_poster ?? my_poster is in beta - please provide feedback (and/or contribute) if you find issues ??️ A lightweight Flutter plugin for making payment

Antonio Mentone 3 Oct 10, 2022
Flutter library for iOS Widgets Extensions. Integrate a Widget into your App 🍏📱

flutter_widgetkit Flutter Library for the iOS ?? WidgetKit framework and Widget Communication Table of Contents ?? Introduction ??‍?? Installation ??‍

Fasky 227 Dec 31, 2022
Plugin to access VPN service for Flutter | Flutter 的 VPN 插件

Flutter VPN plugin This plugin help developers to access VPN service in their flutter app. 本插件帮助开发者在自己的应用内调用 VPN 服务。 The Android part was implemented

Xdea 277 Dec 28, 2022
Community WebView Plugin - Allows Flutter to communicate with a native WebView.

NOTICE We are working closely with the Flutter Team to integrate all the Community Plugin features in the Official WebView Plugin. We will try our bes

Flutter Community 1.4k Jan 7, 2023
Use dynamic and beautiful card view pagers to help you create great apps.

Use dynamic and beautiful card view pagers to help you create great apps. Preview New Feature v1.3.0 Change Alignment Left Center(Default) Right v1.4.

Jeongtae Kim 84 Dec 6, 2022
Android and iOS Geolocation plugin for Flutter

Flutter Geolocator Plugin A Flutter geolocation plugin which provides easy access to platform specific location services (FusedLocationProviderClient

Baseflow 1k Jan 5, 2023
Flutter geolocation plugin for Android and iOS.

geolocation Flutter geolocation plugin for Android API 16+ and iOS 9+. Features: Manual and automatic location permission management Current one-shot

Loup 222 Jan 2, 2023
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 Jan 5, 2023
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