Comments (18)
Called then state.enabled is by default true right?
No. The plugin is disabled by default. Calling .ready(config)
does NOT imply "start tracking". Only calling .start()
initiates tracking.
from cordova-background-geolocation-lt.
If your driver is stopped, you should tell the plugin to .stop()
.
Setting the url
to ''
is not going to stop the plugin continuing to record locations and insert them into its database.
See api docs Config.maxRecordsToPersist
.
from cordova-background-geolocation-lt.
Also read the api docs "HTTP Guide", linked througout.
from cordova-background-geolocation-lt.
If your driver is stopped, you should tell the plugin to
.stop()
.Setting the
url
to''
is not going to stop the plugin continuing to record locations and insert them into its database.See api docs
Config.maxRecordsToPersist
.
@christocracy Thank you very much for your reply!! are you suggesting making the plugin start/stop
with respect to ride start and end? If yes how can I prevent the plugin from recording the locations? Because with .ready()
the plugin starts recording the locations.
from cordova-background-geolocation-lt.
Calling .ready(config)
restores the plugin to its last known state according to State.enabled
.
.start()
->State.enabled == true
.stop()
->State.enabled == false
The plugin stores State.enabled
in permanent storage. It is "remembered" even after app terminate / device reboot.
from cordova-background-geolocation-lt.
If you call .stop()
, terminate then restart your app, you will find that State.enabled == false
and the plugin will NOT call .start()
upon itself after .ready(config)
is called.
BackgroundGeolocation.ready(config).then((state) => {
console.log('State.enabled? ', state.enabled);
});
from cordova-background-geolocation-lt.
For the first time when the app is loaded with .ready()
called then state.enabled
is by default true
right? But in my case i want to track location only when a ride is on-going. So should I call .stop()
at the first time by myself?
from cordova-background-geolocation-lt.
Thanks for your help @christocracy !! I am stuck here for a long time. I'll change my code and check.
from cordova-background-geolocation-lt.
Dear good afternoon, I wanted to ask you if it is mandatory to configure an api (url). I have to make an application that retrieves the coordinates and inserts them into a SQLite database, but the application will not have an internet connection so I cannot configure an API, is it possible for it to work locally? Thank you so much
from cordova-background-geolocation-lt.
No, it's not mandatory. Simply DO NOT even provide an url
.
Be aware that the plug-in inserts each recorded location into its own SQLite db and collects 3 days worth by default. You will may want to configure Config.persistMode
accordingly (PERSIST_MODE_NONE
).
If you wish to take advantage of the plug-in's SQLite db, see .getLocations
and .destroyLocations
.
from cordova-background-geolocation-lt.
Dear, thank you very much for your response. I'll bother you with two more queries if possible. I am setting locationUpdateInterval to 1 second, because I need to show the time in which the vehicle is stopped, the problem I have is that initially the tracking is not executed every one second, until it detects a movement, is this normal? . And the other problem I have is that for example when I am in the "walking" state and I brake there is a delay in changing to the "still" state of approximately 15 seconds, the same when I change from "still" to "walking". I am setting it up as follows:
configureBackgroundGeolocationDos() {
// 1. Listen to events.
BackgroundGeolocation.onLocation(location => {
// Calcular la distancia entre la ubicación actual y la anterior
console.log('[location] - ', location);
this.listaPuntosViaje.push(location.coords)
if (!this.ubicacionAnterior || this.ubicacionAnterior == null) {
this.ubicacionAnterior = location.coords;
return;
}
this.mostrarMensaje("ACTIVIDAD " + location.activity.type)
if (location.activity.type == 'running') { //CORRIENDO
}
if (location.activity.type == 'still') { //CORRIENDO
this.tiempoDeParadaSegundos += 1;
}
if (location.activity.type == 'on_foot') { // A PIE
}
if (location.activity.type == 'on_bicycle') { // EN BICICLETA
}
if (location.activity.type == 'in_vehicle') { // EN VEHICULO
}
if (location.activity.type == 'unknown') { // DESCONOCIDO
}
let velocidad = location.coords.speed == undefined ? 0 : location.coords.speed;
if (velocidad > 0) {
this.velocidad = velocidad * 3.6; // Convertir de m/s a km/h
}
else {
this.velocidad = 0;
}
if (location.activity.type == 'walking' || location.activity.type == 'in_vehicle') {
this.mostrarMensaje(location.activity.type)
const distancia = this.pruebaDistancia(this.ubicacionAnterior.latitude, this.ubicacionAnterior.longitude,
location.coords.latitude, location.coords.longitude)
this.distanciaRecorrida += distancia;
}
this.cdr.detectChanges();
this.ubicacionAnterior = location.coords;
});
BackgroundGeolocation.onMotionChange(event => {
console.log('[motionchange] - ', event.isMoving, event.location);
});
BackgroundGeolocation.onHttp(response => {
console.log('[http] - ', response.success, response.status, response.responseText);
});
BackgroundGeolocation.onProviderChange(event => {
console.log('[providerchange] - ', event.enabled, event.status, event.gps);
});
// 2. Configure the plugin with #ready
BackgroundGeolocation.ready({
reset: true,
debug: true,
logLevel: BackgroundGeolocation.LOG_LEVEL_OFF,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 0,
disableElasticity: true,
locationAuthorizationRequest: "Any",
locationUpdateInterval: 2000,
fastestLocationUpdateInterval: 2000,
maxDaysToPersist: 0, maxRecordsToPersist: 0, //VER ESTO DESHABILITA GUARDAR EN SQLLITE
stopOnStationary: false,
// url: 'http://my.server.com/locations',
allowIdenticalLocations: false,
autoSync: true,
stopOnTerminate: true,
startOnBoot: false, persistMode: BackgroundGeolocation.PERSIST_MODE_NONE,
notification: {
title: 'TEST',
text: 'TEXT',
color: '#FFFFFF',
channelName: 'Geolocation',
priority: -1
},
}, (state) => {
console.log('[ready] BackgroundGeolocation is ready to use');
if (!state.enabled) {
// 3. Start tracking.
BackgroundGeolocation.start();
}
});
}
I hope you can help me and thank you very much in advance!!
from cordova-background-geolocation-lt.
Please learn to syntax highlight fenced codeblocks
from cordova-background-geolocation-lt.
the problem I have is that initially the tracking is not executed every one second, until it detects a movement, is this normal?
The native location api returns locations when it feels like it. The plug-in merely "turns it on".
when I am in the "walking" state and I brake there is a delay in changing to the "still" state of approximately 15 seconds
The same go for the native location api. The plug-in turns it ON -- it's totally up to the OS to return results when it feels like it. There's nothing you can do to "fine tune" it or make it returns results faster.
from cordova-background-geolocation-lt.
Thank you again for your prompt response! One last question, I understand that it is not, but just in case I ask it, there is no functionality that returns the kilometers or meters traveled since BackgroundGeolocation.start() was started; until BackgroundGeolocation.stop()? is finished. This should be calculated by taking the distance between the last coordinate and the new coordinate and accumulating it in a variable, right?
Sorry for the inconvenience and thank you again!
from cordova-background-geolocation-lt.
Search the api docs "odometer"
from cordova-background-geolocation-lt.
Search the api docs "odometer"
Thank you so much!!
from cordova-background-geolocation-lt.
This issue is stale because it has been open for 30 days with no activity.
from cordova-background-geolocation-lt.
This issue was closed because it has been inactive for 14 days since being marked as stale.
from cordova-background-geolocation-lt.
Related Issues (20)
- Missing $BACKGROUND_MODE_LOCATION in UIBackgroundModes HOT 4
- Not sending data along with the URL HOT 9
- API calls to backend server calling pending in the background mode after 5 minutes HOT 5
- [documentation] Missing wiki page "Solving Build Failures" when following a link in the REAME HOT 4
- Distance is not coming as per actual distance travelled. HOT 3
- location updates on Android, Xiaomi HOT 3
- IOS - clang: error: linker command failed with exit code 1 (use -v to see invocation) HOT 22
- Persistent display in iOS dynamic island HOT 8
- Odometer remains 0 on one phone (Redmi 9T) out of 500 users HOT 3
- The app is terminating in the background (Android). HOT 22
- Getting Accuracy more than 100 HOT 7
- autosync not merging data after device is back on wifi HOT 3
- iOS 17 blocking requests with a 30-second timeout in the settings. HOT 9
- Build failing with plugin HOT 1
- Plugin crashing during app build HOT 5
- Android app crash in few device HOT 3
- Certificate for <developer.huawei.com> doesn't match any of the subject alternative names HOT 8
- Plugin v 4.16.1 crashed on android: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected HOT 3
- Location is not recording while in sleep mode HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-background-geolocation-lt.