Giter Club home page Giter Club logo

background_location's Introduction

Background Location

A Flutter plugin to get location updates in the background for both Android and iOS (Requires iOS 10.0+). Uses CoreLocation for iOS and FusedLocationProvider for Android

Getting Started

1: Add this to your package's pubspec.yaml file:

dependencies:
  background_location: ^0.13.0

2: Install packages from the command line:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

How to use

Import the package where you wanna use it.

import 'package:background_location/background_location.dart';

Request permissions from the user. You can use permission_handler for this

Set the notification title, message and icon (Android only). Use await or .then if you wanna start the location service immediatly after becuase its an asynchronous method

BackgroundLocation.setAndroidNotification(
	title: "Notification title",
        message: "Notification message",
        icon: "@mipmap/ic_launcher",
);

Set the interval between localisations in milliseconds (Android only). Use await or .then if you wanna start the location service immediatly after becuase its an asynchronous method

BackgroundLocation.setAndroidConfiguration(1000);

Start the location service. This will also ask the user for permission if not asked previously by another package.

BackgroundLocation.stopLocationService(); //To ensure that previously started services have been stopped, if desired
BackgroundLocation.startLocationService();

Note: There is currently an open issue (#10) where, if the location service is started multiple times, the location callback will get called repeatedly. This can be worked around by calling BackgroundLocation.stopLocationService(); to stop any previous running services (such as from a previous run of the app) before starting a new one.

Start location service by specifying distanceFilter. Defaults to 0 if not specified

BackgroundLocation.startLocationService(distanceFilter : 10);

You can also force the use of Android LocationManager instead of Google's FusedLocationProvider by setting the forceAndroidLocationManager property to true. If not specified, this defaults to false, which uses FusedLocationProvider if it is available, treating LocationManager as a fallback. This setting has no effect on iOS devices.

BackgroundLocation.startLocationService(forceAndroidLocationManager: true);

getLocationUpdates will trigger everytime the location updates on the device. Provide a callback function to getLocationUpdates to handle location update.

BackgroundLocation.getLocationUpdates((location) {
  print(location);
});

location is a Class exposing the following properties.

double latitude;
double longitude;
double altitude;
double bearing;
double accuracy;
double speed;
double time;
bool isMock;

To stop listening to location changes you can execute.

BackgroundLocation.stopLocationService();

Make sure to delcare all required permissions for both your android and ios app

info.plist

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location.</string>
<key>UIBackgroundModes</key>
<array>
	<string>fetch</string>
	<string>location</string>
</array>

AndroidManifest.xml

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

background_location's People

Contributors

almoullim avatar ambernardino avatar amirthapa avatar asapj avatar brvier avatar bwmuller avatar cadivus avatar cormalenv avatar cristiancy96 avatar cybersokari avatar hesty avatar hilalbaig avatar isseikanda avatar jeffmikels avatar juliansteenbakker avatar lclrobert2020 avatar luis901101 avatar lukaskurz avatar mahanpyk avatar moralcode avatar nullbyte08 avatar rubenvde avatar sanjog12 avatar sly2024 avatar sofferjacob avatar stevehayles avatar takish avatar themisir avatar toto850105 avatar yoavrofe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

background_location's Issues

MissingPluginException (MissingPluginException(No implementation found for method set_notification_title on channel almoullim.com/background_location))

Versions using:
background_location: ^0.2.1+1
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.2, on Microsoft Windows [Version 10.0.17134.1304], locale en-US)

Am able to run the example provided with plugin source code from github and whenever am trying to integrate this plugin into my app and am getting MissingPluginException as mentioned above.

Did I miss anything (I followed the steps provided in Readme section) , Can anyone please check whether its working or am the only one getting the issue?

compiler permission == PermissionStatus.disabled error

Compiler message:
../../flutter/.pub-cache/hosted/pub.dartlang.org/background_location-0.0.9+2/lib/background_location.dart:49:88: Error: Getter not found: 'disabled'.
} else if (permission == PermissionStatus.denied || permission == PermissionStatus.disabled || permission == PermissionStatus.restricted || permission == PermissionStatus.unknown) {
^^^^^^^^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.

FAILURE: Build failed with an exception.

Do not get location in background after close the app

  • I have read the README
  • I have done the setup for Android
  • I have done the setup for iOS
  • I have ran the sample app and it does not work there

Version

Technology Version
background_location version 0.0.9+3

Describe the error
After closing the application the service does not continue running in the background and records these messages in the Android Studio logcat

E/ActivityThread(10619): Activity br.com.infogen.gpstracker.MainActivity has leaked ServiceConnection com.almoullim.background_location.BackgroundLocationPlugin$mServiceConnection$1@1f88f6 that was originally bound here
E/ActivityThread(10619): android.app.ServiceConnectionLeaked: Activity br.com.infogen.gpstracker.MainActivity has leaked ServiceConnection com.almoullim.background_location.BackgroundLocationPlugin$mServiceConnection$1@1f88f6 that was originally bound here
E/ActivityThread(10619): 	at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1619)
E/ActivityThread(10619): 	at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1511)
E/ActivityThread(10619): 	at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1674)
E/ActivityThread(10619): 	at android.app.ContextImpl.bindService(ContextImpl.java:1627)
E/ActivityThread(10619): 	at android.content.ContextWrapper.bindService(ContextWrapper.java:698)
E/ActivityThread(10619): 	at com.almoullim.background_location.BackgroundLocationPlugin.onMethodCall(BackgroundLocationPlugin.kt:83)
E/ActivityThread(10619): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/ActivityThread(10619): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/ActivityThread(10619): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/ActivityThread(10619): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/ActivityThread(10619): 	at android.os.MessageQueue.next(MessageQueue.java:326)
E/ActivityThread(10619): 	at android.os.Looper.loop(Looper.java:160)
E/ActivityThread(10619): 	at android.app.ActivityThread.main(ActivityThread.java:6923)
E/ActivityThread(10619): 	at java.lang.reflect.Method.invoke(Native Method)
E/ActivityThread(10619): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/ActivityThread(10619): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
W/FlutterJNI(10619): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: almoullim.com/background_location. Response ID: 0
I/chatty  (10619): uid=10477(br.com.infogen.gpstracker) identical 1 line
W/FlutterJNI(10619): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: almoullim.com/background_location. Response ID: 0

Output of flutter doctor -v

C:\KB\Android\GPSTracker\gpstracker>flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [versão 10.0.17763.914], locale pt-BR)
    • Flutter version 1.12.13+hotfix.8 at C:\src\flutter
    • Framework revision 0b8abb4724 (5 weeks ago), 2020-02-11 11:44:36 -0800
    • Engine revision e1e6ced81d
    • Dart version 2.7.0


[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\Users\infogen-desenv-7000\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 40.1.2
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] Connected device (1 available)
    • moto g 6 play • 0046718621 • android-arm • Android 9 (API 28)

• No issues found!

background_location: ^0.3.0 not stable

I tried updating my existing package to this new one. It gives me the following error upon running the example app as well as when I run my existing app.

Launching lib\main.dart on ASUS X00TD in debug mode...
lib\main.dart
Parameter format not correct -
e: C:\Users\Gautam Vashishtha\flutter.pub-cache\hosted\pub.dartlang.org\background_location-0.2.2+2\android\src\main\kotlin\com\almoullim\background_location\BackgroundLocationPlugin.kt: (24, 7): Redeclaration: BackgroundLocationPlugin
e: C:\Users\Gautam Vashishtha\flutter.pub-cache\hosted\pub.dartlang.org\background_location-0.2.2+2\android\src\main\kotlin\com\almoullim\background_location\LocationUpdatesService.kt: (16, 7): Redeclaration: LocationUpdatesService
e: C:\Users\Gautam Vashishtha\flutter.pub-cache\hosted\pub.dartlang.org\background_location-0.3.0\android\src\main\kotlin\com\almoullim\background_location\BackgroundLocationPlugin.kt: (24, 7): Redeclaration: BackgroundLocationPlugin
e: C:\Users\Gautam Vashishtha\flutter.pub-cache\hosted\pub.dartlang.org\background_location-0.3.0\android\src\main\kotlin\com\almoullim\background_location\BackgroundLocationPlugin.kt: (91, 73): Unresolved reference: NOTIFICATION_MESSAGE

e: C:\Users\Gautam Vashishtha\flutter.pub-cache\hosted\pub.dartlang.org\background_location-0.3.0\android\src\main\kotlin\com\almoullim\background_location\BackgroundLocationPlugin.kt: (92, 70): Unresolved reference: NOTIFICATION_ICON
e: C:\Users\Gautam Vashishtha\flutter.pub-cache\hosted\pub.dartlang.org\background_location-0.3.0\android\src\main\kotlin\com\almoullim\background_location\BackgroundLocationPlugin.kt: (95, 31): Unresolved reference: updateNotification
e: C:\Users\Gautam Vashishtha\flutter.pub-cache\hosted\pub.dartlang.org\background_location-0.3.0\android\src\main\kotlin\com\almoullim\background_location\BackgroundLocationPlugin.kt: (102, 43): Val cannot be reassigned

e: C:\Users\Gautam Vashishtha\flutter.pub-cache\hosted\pub.dartlang.org\background_location-0.3.0\android\src\main\kotlin\com\almoullim\background_location\BackgroundLocationPlugin.kt: (102, 66): Cannot access 'UPDATE_INTERVAL_IN_MILLISECONDS': it is private in 'Companion'
e: C:\Users\Gautam Vashishtha\flutter.pub-cache\hosted\pub.dartlang.org\background_location-0.3.0\android\src\main\kotlin\com\almoullim\background_location\LocationUpdatesService.kt: (15, 7): Redeclaration: LocationUpdatesService

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':background_location:compileDebugKotlin'.

Compilation error. See log for more details

  • 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 2m 10s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

Does not compile on Android

I added "background_location: ^0.1.2" in pubspec.yaml without any other changes. After that my app would not compile. My app would compile before adding that 1 line in pubspec.yaml. The following are the error messages:

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:mergeDebugJavaResource'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
File 'com.android.builder.files.ZipCentralDirectory@7817ff47' was deleted, but previous version not found in cache

Slow gps rate

BackgroundLocation.startLocationService();
BackgroundLocation.getLocationUpdates((location) {
  print(DateTime.now().toIso8601String());
});

I/flutter (25803): 2020-08-05T17:11:17.728799
I/flutter (25803): 2020-08-05T17:11:26.954644
I/flutter (25803): 2020-08-05T17:11:36.168458
I/flutter (25803): 2020-08-05T17:11:45.502994
I/flutter (25803): 2020-08-05T17:11:54.833921
I/flutter (25803): 2020-08-05T17:12:04.750329
I/flutter (25803): 2020-08-05T17:12:15.789310
I/flutter (25803): 2020-08-05T17:12:25.905644
I/flutter (25803): 2020-08-05T17:12:36.014842
I/flutter (25803): 2020-08-05T17:12:45.927024
I/flutter (25803): 2020-08-05T17:12:55.899358
I/flutter (25803): 2020-08-05T17:13:05.995847

Any way to get location faster? Right now it works every 10 seconds, i need 3 seconds

Application closed

It's working when application is sent to back but it's not working when application is killed. Am I missing something?

Doesn't build for iOS due to SWIFT VERSION unstated

  • background_location does not specify a Swift version and none of the targets (Runner) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod.

Any help please

Launch app when notification press

  1. Add fun getMainActivityClass()

  2. Add val pendingIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT)

  3. setContentIntent(pendingIntent)

` private val notification: NotificationCompat.Builder
get() {
// val intent = Intent(this, LocationUpdatesService::class.java)
val intent = Intent(this, getMainActivityClass(this))
intent.putExtra(EXTRA_STARTED_FROM_NOTIFICATION, true)
val pendingIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT)
val builder = NotificationCompat.Builder(this)
.setContentTitle(NOTIFICATION_TITLE)
.setOngoing(true)
.setSound(null)
.setContentIntent(pendingIntent)
.setPriority(Notification.PRIORITY_HIGH)
.setSmallIcon(R.drawable.navigation_empty_icon)
.setWhen(System.currentTimeMillis())

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            builder.setChannelId(CHANNEL_ID)
        }

        return builder
    }`

private fun getMainActivityClass(context: Context): Class<*>? { val packageName = context.packageName val launchIntent = context.packageManager.getLaunchIntentForPackage(packageName) val className = launchIntent?.component?.className return try { Class.forName(className) } catch (e: ClassNotFoundException) { e.printStackTrace() null } }

App crash: java.lang.RuntimeException

The error occurred on Android 5.1 (SDK 22)

The error is caused by a type cast exception. The logs show the following:

java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:2845)
at android.app.ActivityThread.access$1700 (ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1547)
at android.os.Handler.dispatchMessage (Handler.java:111)
at android.os.Looper.loop (Looper.java:194)
at android.app.ActivityThread.main (ActivityThread.java:5637)
at java.lang.reflect.Method.invoke (Method.java)
at java.lang.reflect.Method.invoke (Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:754)
Caused by: kotlin.TypeCastException:
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.access$initializeService (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.access$isRegisterLocator (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.access$registerLocator (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.access$removeLocator (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.getAccuracy (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.getCallbackHandle (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.getLocationRequest (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.initializeService (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.isRegisterLocator (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.registerAfterBoot (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.registerLocator (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.removeLocator (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.setCallbackDispatcherHandle (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.setCallbackHandle (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.setDataCallback (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.access$initializeService (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.access$isRegisterLocator (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.access$registerLocator (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.access$removeLocator (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.getAccuracy (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.getCallbackHandle (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.getLocationRequest (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.initializeService (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.isRegisterLocator (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.registerAfterBoot (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.registerLocator (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.removeLocator (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.setCallbackDispatcherHandle (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.setCallbackHandle (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BackgroundLocatorPlugin$Companion.setDataCallback (BackgroundLocatorPlugin.java)
at rekab.app.background_locator.BootBroadcastReceiver.onReceive (BootBroadcastReceiver.java)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:2838)
at android.app.ActivityThread.access$1700 (ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1547)
at android.os.Handler.dispatchMessage (Handler.java:111)
at android.os.Looper.loop (Looper.java:194)
at android.app.ActivityThread.main (ActivityThread.java:5637)
at java.lang.reflect.Method.invoke (Method.java)
at java.lang.reflect.Method.invoke (Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:754)

Not working on iOS

I followed the instructions in the README to add this to my app and on iOS I'm not getting any location updates. I'm not getting any errors or messages, the getLocationUpdates is just not triggering. I have location permissions enabled. On Android it works perfectly.

The example app works fine on both iOS and Android, so it must be something to do with my implementation, but I don't know what steps I could have missed.

Location service status

Hello,

how is it possible to know if Location Service is enabled with this plugin?
When Location is "stopped" on the device when application is running, the last position remains.
But, I want to "reset" this value but It's not possible to know if BackgroundLocation service was stopped... :-(

Would have you got a workaround about this ask!?

Thanks

Crash on boot

Hi to all,
after I added the background_location: ^0.2.2 dependency my app crashes on boot when I start it from my iOS device.

If I run the app from Android Studio/Xcode it works correctly.

The error I was able to get from Xcode console is the following:

RBSStateCapture remove item called for untracked item 32-60-11186 (target:[application<com.sromano.uberclone>:2185](UIScene:com.apple.frontboard.systemappservices::sceneID%3Acom.sromano.uberclone-default))

How can I resolve this issue?

Thanks in advance
Simone

Check if the location service is already running

Every time if I restart the application, a new location service starts and count of the same locations increase.

void _getLocation(){
    BackgroundLocation.startLocationService();
    BackgroundLocation.getLocationUpdates((dynamic position) =>
      print(position));
}

error on flutter build iOS

Hi All,

I'm getting the following error when trying to build for iOS.

[!] CocoaPods could not find compatible versions for pod
"background_location":
In Podfile:
background_location (from .symlinks/plugins/background_location/ios)

In iOS, Blue Indicator appears even of the location permission is set to always

When the location is set to 'Allow Always' in iOS, in native code you can set showsBackgroundLocationIndicator in the LocationManager to false and the blue location indicator will stop appearing (while it will stay appearing if the user enabled the permission "while in use").

In this library I cannot see this option, and in case you requested the location while the user enabled "Always" permission the blue indicator will appear all the time.

Is there an option to hide this indicator ?

Cannot run on IOS 8/9/11 getting following issue.

Running pod install... 4.0s
CocoaPods' output:

Preparing

Analyzing dependencies

Inspecting targets to integrate
  Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

Fetching external sources
-> Fetching podspec for `Flutter` from `Flutter`
-> Fetching podspec for `background_location` from `.symlinks/plugins/background_location/ios`
-> Fetching podspec for `location` from `.symlinks/plugins/location/ios`
-> Fetching podspec for `location_web` from `.symlinks/plugins/location_web/ios`
-> Fetching podspec for `move_to_background` from `.symlinks/plugins/move_to_background/ios`
-> Fetching podspec for `permission_handler` from `.symlinks/plugins/permission_handler/ios`
-> Fetching podspec for `workmanager` from `.symlinks/plugins/workmanager/ios`

Resolving dependencies of `Podfile`
  CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
[!] CocoaPods could not find compatible versions for pod "background_location":
  In Podfile:
    background_location (from `.symlinks/plugins/background_location/ios`)

Specs satisfying the `background_location (from `.symlinks/plugins/background_location/ios`)` dependency were found, but they required a higher minimum deployment target.

/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:328:in `raise_error_unless_state'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:310:in `block in unwind_for_conflict'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `tap'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `unwind_for_conflict'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:684:in `attempt_to_activate'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:254:in `process_topmost_state'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/resolver.rb:94:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/analyzer.rb:1065:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/analyzer.rb:1063:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:410:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:235:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:234:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:156:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

Error output from CocoaPods:

[!] 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. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

Error running pod install
Error launching application on iPhone 11 Pro.

Not Working in ios14

  void findLocation(int endTimeStamp) async {
    await BackgroundLocation.setNotificationTitle("Test Title");
    await BackgroundLocation.startLocationService();
    await BackgroundLocation.getLocationUpdates((location) async {
    	print(location.accuracy);
    });
  }

this is my code
working in android but not working in ios

crashing the application after calling startLocationService even if permission is granted for location

onPressed: () {
try {
BackgroundLocation.checkPermissions().then((status) {
// Check status here
if (status == PermissionStatus.granted) {
BackgroundLocation.startLocationService();
BackgroundLocation.getLocationUpdates((location) {
print(location.latitude.toString() +
"-" +
location.longitude.toString());
});
} else if (status == PermissionStatus.disabled ||
status == PermissionStatus.denied) {
BackgroundLocation.getPermissions(onGranted: () {
BackgroundLocation.startLocationService();
BackgroundLocation.getLocationUpdates((location) {
print("loaction:" +
location.latitude.toString() +
"-" +
location.longitude.toString());
});
}, onDenied: () {
BackgroundLocation?.stopLocationService();
});
}
});
} catch (e) {
print(e.toString());
}
},

Foreground service notification shows 'Stop Service' option.

If I run a foreground service from a native app, the users don't have option to stop service within notification.
But when I do the same with this package, the users have option to stop service. Please see the differences in images. Is it because it's a bound service? Also when I force stop service in native app, the app terminates too. But with this package I can stop the service without affecting the app. Is it possible to achieve same behaviour as native. Any hep would be much appreciated.

2
1

Never stops background!

Hi Almoullim!

When I kill the app the service keep running in background.

log: FlutterView.send called on a detached view, channel=almoullim.com/background_location

When app starts again, the getLocationUpdates callback fire many times.

Does this code work?

I cannot get it running in the simulator or with my Pixel 3a.
I am running the example app.
It just says waiting...

Speed

what is the unit of measurement for speed?

kilometers / hour
mile / hour
meters / hour ...

Does not receive background updates in emulator.

The package does not seem to receive background updates on Android when the emulator's screen is off(I presume the off button on the emulator is simply just the screen being off and not the device).

The package, however, does work well if you have the screen on, the active app is google maps and the app is in the background.

SWIFT_VERSION Error

  • background_location does not specify a Swift version and none of the targets (Runner) integrating it have the
    SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets
    that integrate this pod.

When i try run "flutter build ios" command, i get this error code.

Do not update on android

Hi,
I have tested the background_location example with latest flutter (flutter_macos_1.22.1-stable) and Android Studio (4.0.2) on AVD device (Pixel 3 API 30, Android 10+ 86) and on real Android device.
Manual update works, but no automatic update on both devices.

any help ?

best regards
jg

setAndroidConfiguration throws Exception about java.lang.Long

Not completely sure so didn't get a PR.

BackgroundLocationPlugin.kt around L100
Should be like this maybe?

            call.method == "set_configuration" -> {
                val timeInterval: String? = call.argument("interval");
                if (timeInterval != null) LocationUpdatesService.UPDATE_INTERVAL_IN_MILLISECONDS = timeInterval.toLong()

                result.success(0);
            }

Crash when used with other plugin (WorkManager)

I would like to use this background_plugin in addition with the workmanager plugin.
Workmanager (https://pub.dev/packages/workmanager) needs to register a callback in an overloaded Android application

When started I get a crash:
java.lang.IllegalStateException: registrar.activity() must not be null
E/AndroidRuntime( 7146): at com.almoullim.background_location.BackgroundLocationPlugin$Companion.registerWith(BackgroundLocationPlugin.kt:37)
E/AndroidRuntime( 7146): at com.almoullim.background_location.BackgroundLocationPlugin.registerWith(Unknown Source:2)
E/AndroidRuntime( 7146): at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:42)
E/AndroidRuntime( 7146):

Customize icon, text and optional action button.

The plugin works fine but there is no icon when I run example project.
image
Could you add some customization options for the icon, icon color, text and make "Stop location service" action optional?

ios cocoapods issue

[!] CocoaPods could not find compatible versions for pod "background_location":
In Podfile:
background_location (from .symlinks/plugins/background_location/ios)

Specs satisfying the background_location (from .symlinks/plugins/background_location/ios) dependency were found, but they required a higher minimum deployment target.

for iOS it stopped after 3 mins.

Hi, This Plugin for Android is working properly. but for iOS its stopped after 3mins. (Default time for iOS to send App to Sleep). Then updating stopped. please check.

Ask about accuracy

Hey, big thanks for this plugin.

I do notice location class with properties like speed, bearing, accuracy, etc. Because of getting device location isn't always give a real location, sometimes it went far away from my location, so I want to know what is accuracy properties in location class.
I was able to print it, but it gave me numeric return like 15.656999588012695, 14.217000007629395, etc. But actually I don't understand what it means. The lower its number the more accuracy its location or otherwise, or something else?
And how can we say that the accuracy is at its best or worst (for example if the accuracy number below 20 can we say that the location is good or not?)

Big Thanks.

Android memory leak when terminating the app with active foreground service

2019-09-19 17:56:59.699 1728-1965/? W/SurfaceFlinger: Attempting to destroy on removed layer: AppWindowToken{a171bab token=Token{68e89fa ActivityRecord{d069425 u0 com.example.backgeound_location_example/.MainActivity t138}}}#0
2019-09-19 17:56:59.702 8072-8072/com.example.backgeound_location_example E/ActivityThread: Activity com.example.backgeound_location_example.MainActivity has leaked ServiceConnection com.almoullim.background_location.BackgroundLocationPlugin$mServiceConnection$1@7049b1 that was originally bound here
    android.app.ServiceConnectionLeaked: Activity com.example.backgeound_location_example.MainActivity has leaked ServiceConnection com.almoullim.background_location.BackgroundLocationPlugin$mServiceConnection$1@7049b1 that was originally bound here
        at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1610)
        at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1502)
        at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1659)
        at android.app.ContextImpl.bindService(ContextImpl.java:1612)
        at android.content.ContextWrapper.bindService(ContextWrapper.java:698)
        at com.almoullim.background_location.BackgroundLocationPlugin.onMethodCall(BackgroundLocationPlugin.kt:83)
        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
        at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
        at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:326)
        at android.os.Looper.loop(Looper.java:160)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2019-09-19 17:56:59.706 1891-2430/? W/ActivityManager: Unbind failed: could not find connection for android.os.BinderProxy@2143468

Get the location updates after each 1 minute?

Hi, I want to create an app like Uber, and I want to get the location updates of the user after each 1 minute even if the app is running in the background is there a way to do this using your library?

I want the solution to work for both Android and Ios.

kindly let me know Thanks.

conflict with firebase_messaging plugin

Hi!
I work on a project where i use the firebase_messaging plugin.
If i add this background_location plugin to the project, when i run the app i receive this error:

E/AndroidRuntime( 9189): java.lang.RuntimeException: Unable to create service io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService: java.lang.IllegalStateException: registrar.activity() must not be null
E/AndroidRuntime( 9189): at android.app.ActivityThread.handleCreateService(ActivityThread.java:3544)
E/AndroidRuntime( 9189): at android.app.ActivityThread.access$1300(ActivityThread.java:199)
E/AndroidRuntime( 9189): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1666)
E/AndroidRuntime( 9189): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 9189): at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime( 9189): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/AndroidRuntime( 9189): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 9189): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime( 9189): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/AndroidRuntime( 9189): Caused by: java.lang.IllegalStateException: registrar.activity() must not be null
E/AndroidRuntime( 9189): at com.almoullim.background_location.BackgroundLocationPlugin$Companion.registerWith(BackgroundLocationPlugin.kt:37)
E/AndroidRuntime( 9189): at com.almoullim.background_location.BackgroundLocationPlugin.registerWith(Unknown Source:2)
E/AndroidRuntime( 9189): at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:16)
E/AndroidRuntime( 9189): at com.example.my_background_location.Application.registerWith(Application.java:18)
E/AndroidRuntime( 9189): at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.startBackgroundIsolate(FlutterFirebaseMessagingService.java:164)
E/AndroidRuntime( 9189): at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.onCreate(FlutterFirebaseMessagingService.java:77)
E/AndroidRuntime( 9189): at android.app.ActivityThread.handleCreateService(ActivityThread.java:3532)

Steps to reproduce:

  1. create new flutter project with Java support

  2. add to pubspec.yaml:

firebase_messaging: ^5.1.6
background_location:
path: ../background_location-master

  1. follow Android installation instructions from here: https://pub.dev/packages/firebase_messaging#-readme-tab-

  2. run the app

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.