loup-v / geolocation

Flutter geolocation plugin for Android and iOS.
Apache License 2.0
226 stars 94 forks source link

Does it work if the app is closed ? #57

Open mhassanist opened 4 years ago

mhassanist commented 4 years ago

"Flutter plugin for location / geolocation / GPS. Supports iOS and Android. Multiple settings for speed, precision, battery optimization, continuous updates in background "

In background here means we can keep updates even the app is not in foreground (closed may be by the system or when click back).

angel-r commented 4 years ago

+1

GadepalliAditya1998 commented 4 years ago

I guess it wont work, because its not requesting for background location permission and its not even using any background service codes specific to platform. it works in background according to flutter, but will stop updates as soon as the app is closed.

radvansky-tomas commented 4 years ago

Tried on iphone 11, latest iOS, no background updates!

RomanJos commented 4 years ago

It doesn't work with

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
ghost commented 4 years ago

For background processing on IOS, it works when adding: locationManager.allowsBackgroundLocationUpdates = true

in: geolocation/ios/Classes/Location/LocationClient.swift

class LocationClient : NSObject, CLLocationManagerDelegate {
.......
.......
override init() {
    super.init()
    locationManager.delegate = self
    locationManager.allowsBackgroundLocationUpdates = true   // <---
  }

and adding in: ios/Runner/Info.plist

<key>UIBackgroundModes</key>
    <array>
        <string>location</string>
    </array>