-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Background service not running on first call #103
Comments
Same happen to me. This bug began in version ^0.6.1, before that version the notification starts at the first call. |
Digging a bit more I found that the issue is not only the notification not showing at first call but also the background location not starting. Some examples for better understanding of the issue:
Note 1: the app in the examples uses geolocator ^7.2.0+1 for foreground locations |
Hey man so if you switch back to 0.6.0 it worked? Im having trouble receiving callbacks when I navigate away from the app and into the background. Heres my code: https://github.com/blaqkrow/location_tracking_flutter |
Yes, using version 0.6.0 works fine, to ensure using that especific version you should set background_location: 0.6.0 in your pubspec, the tip here is not to use the ^ at the begining of the version. |
The answer from @luis901101 saved my day: just change the version from pubspec.yaml from |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
I implemented this package to get background location, However, the service won't start on the first call and performs normally on the second and following calls.
`ElevatedButton(
child:Text("Start),
onPressed()async{
await bg.BackgroundLocation
.setAndroidNotification(
title: 'Background service is running',
message:
'Background location in progress',
icon: '@drawable/ic_notification',
);
await bg.BackgroundLocation
.setAndroidNotification(
title: 'Background service is running',
message:
'Background location in progress',
icon: '@drawable/ic_notification',
);
//await BackgroundLocation.setAndroidConfiguration(1000);
await bg.BackgroundLocation
.startLocationService(
distanceFilter: 200);
await bg.BackgroundLocation
.startLocationService(
distanceFilter: 200);
bg.BackgroundLocation.getLocationUpdates(
(location) {
print("Location updated"+location.toString());
});
}
)`
When clicked on the button that calls the service, no error is printed and works fine when clicked for second time.
My flutter doctor is below
Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 2.0.6, on Microsoft Windows [Version 10.0.14393], locale en-IN) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [√] Chrome - develop for the web [√] Android Studio (version 4.1.0) [√] VS Code (version 1.57.1) [√] Connected device (2 available)
The text was updated successfully, but these errors were encountered: