Comments (13)
Do you know you need to travel at least 200 meters before tracking engages? You need to go outside and move.
from react-native-background-geolocation.
Yes, I walked 5000 meters and it didn't send data to Firebase
from react-native-background-geolocation.
I’m not concerned about your Firebase. Does the plug-in make debug sound FX?
learn to fetch and analyze the plug-in logs. See wiki “Debugging”. Search api docs “emailLog”
from react-native-background-geolocation.
Issued, is it not compatible with realtime firebase?
from react-native-background-geolocation.
You’re responsible for your own JavaScript code implementing Firebase. That’s not the plug-ins responsibility.
im only concerned with “does the plugin track location and emit debug soundFX.
from react-native-background-geolocation.
Please learn to syntax highlight codeblocks:
https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks
from react-native-background-geolocation.
BackgroundGeolocation.ready({
// Geolocation Config
backgroundPermissionRationale: {
title: 'Permitir acesso à sua localização em background',
message:
'Para obter sua localização com precisão, por favor permita que o App obtenha sua localização o tempo todo.',
positiveAction: 'Configurar',
negativeAction: 'Cancelar',
},
locationAuthorizationAlert: {
titleWhenOff: 'Localização indisponível',
titleWhenNotEnabled: 'Localização em background indisponível',
instructions:
'Para obter sua localização com precisão, por favor permita que o App obtenha sua localização o tempo todo.',
settingsButton: 'Configurar',
cancelButton: 'Cancelar',
},
notification: {
title: 'Acompanhando sua localização',
text: 'Acompanhamos sua localização para enviar corridas próximas e monitorar a entrega.',
},
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 10,
// Activity Recognition
stopTimeout: 5,
// Application config
debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
startOnBoot: true, // <-- Auto start tracking when device is powered-up.
// HTTP / SQLite config
url: 'https://shark-app-j3vbs.ondigitalocean.app/geolocationbackground',
batchSync: false, // <-- [Default: false] Set true to sync locations to server in a single HTTP request.
autoSync: true, // <-- [Default: true] Set true to sync each location to server as it arrives.
headers: { // <-- Optional HTTP headers
// "X-FOO": "bar"
"Authorization": `Bearer ${prestador.token}`
},
params: { // <-- Optional HTTP params
// "auth_token": "maybe_your_server_authenticates_via_token_YES?"
"prestador_id": prestador.id,
"nome": prestador.nome,
"genero": prestador.genero,
"foto_perfil": prestador.foto_perfil,
"prestadorsubcategoria": prestador.prestadorsubcategoria
}
}).then((state) => {
setEnabled(state.enabled)
console.log("- BackgroundGeolocation is configured and ready: ", state.enabled);
});
Do I need to do something special to send the parameters? It's only arriving with the screen on.
from react-native-background-geolocation.
See api docs .emailLog. Learn to fetch and observe the plug-in logs.
and get rid of this: you do NOT need to do this.
if (error.message === "Waiting for previous start action to complete") {
BackgroundGeolocation.stop().then(() => {
console.log("BackgroundGeolocation stopped, restarting...");
BackgroundGeolocation.start().then(() => {
console.log("BackgroundGeolocation restarted");
}).catch(error => {
console.error("Error restarting BackgroundGeolocation: ", error);
});
}).catch(stopError => {
console.error("Error stopping BackgroundGeolocation: ", stopError);
});
} else {
console.error("Error starting BackgroundGeolocation: ", error);
}
from react-native-background-geolocation.
import React, { useContext } from 'react';
import { Switch, Text, View, PermissionsAndroid } from 'react-native';
import BackgroundGeolocation from "react-native-background-geolocation";
import { AuthContext } from '../../contexts/AuthContext';
import api from '../../services/api';
const HelloWorld = () => {
const [enabled, setEnabled] = React.useState(false);
const [location, setLocation] = React.useState('');
const { prestador } = useContext(AuthContext);
React.useEffect(() => {
const requestLocationPermissions = async () => {
try {
const granted = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,
PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION,
]);
if (
granted['android.permission.ACCESS_FINE_LOCATION'] === PermissionsAndroid.RESULTS.GRANTED &&
granted['android.permission.ACCESS_COARSE_LOCATION'] === PermissionsAndroid.RESULTS.GRANTED &&
granted['android.permission.ACCESS_BACKGROUND_LOCATION'] === PermissionsAndroid.RESULTS.GRANTED
) {
console.log('Você tem todas as permissões de localização');
} else {
console.log('Permissões de localização negadas');
}
} catch (err) {
console.warn(err);
}
};
requestLocationPermissions();
const onLocation = BackgroundGeolocation.onLocation(async (location) => {
console.log('[onLocation]', location);
setLocation(JSON.stringify(location, null, 2));
let dados = {
"prestador_id": prestador.id,
"nome": prestador.nome,
"genero": prestador.genero,
"foto_perfil": prestador.foto_perfil,
"prestadorsubcategoria": prestador.prestadorsubcategoria,
"location": {
"coords": {
"latitude": location.coords.latitude,
"longitude": location.coords.longitude,
}
}
};
try {
const response = await api.post('/geolocationbackground/', dados, {
headers: {
'Authorization': `Bearer ${prestador.token}`
}
});
console.log('Post successful: ', response.data);
} catch (error) {
console.error('Post failed: ', error);
}
});
const onMotionChange = BackgroundGeolocation.onMotionChange((event) => {
console.log('[onMotionChange]', event);
});
const onActivityChange = BackgroundGeolocation.onActivityChange((event) => {
console.log('[onActivityChange]', event);
});
const onProviderChange = BackgroundGeolocation.onProviderChange((event) => {
console.log('[onProviderChange]', event);
});
BackgroundGeolocation.ready({
backgroundPermissionRationale: {
title: 'Permitir acesso à sua localização em background',
message: 'Para obter sua localização com precisão, por favor permita que o App obtenha sua localização o tempo todo.',
positiveAction: 'Configurar',
negativeAction: 'Cancelar',
},
locationAuthorizationAlert: {
titleWhenOff: 'Localização indisponível',
titleWhenNotEnabled: 'Localização em background indisponível',
instructions: 'Para obter sua localização com precisão, por favor permita que o App obtenha sua localização o tempo todo.',
settingsButton: 'Configurar',
cancelButton: 'Cancelar',
},
notification: {
title: 'Acompanhando sua localização',
text: 'Acompanhamos sua localização para enviar corridas próximas e monitorar a entrega.',
},
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 10,
stopTimeout: 5,
debug: true,
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
stopOnTerminate: false,
startOnBoot: true,
url: 'https://shark-app-j3vbs.ondigitalocean.app/geolocationbackground',
batchSync: false,
autoSync: true,
headers: {
"Authorization": `Bearer ${prestador.token}`
},
params: {
"prestador_id": prestador.id,
"nome": prestador.nome,
"genero": prestador.genero,
"foto_perfil": prestador.foto_perfil,
"prestadorsubcategoria": prestador.prestadorsubcategoria
}
}).then((state) => {
setEnabled(state.enabled);
console.log("- BackgroundGeolocation is configured and ready: ", state.enabled);
let Logger = BackgroundGeolocation.logger;
Logger.emailLog('[email protected]')
.then(success => {
console.log(success, '[emailLog] success');
})
.catch(error => {
console.log('[emailLog] FAILURE: ', error);
});
});
return () => {
onLocation.remove();
onMotionChange.remove();
onActivityChange.remove();
onProviderChange.remove();
};
}, []);
React.useEffect(() => {
if (enabled) {
BackgroundGeolocation.start();
} else {
BackgroundGeolocation.stop();
setLocation('');
}
}, [enabled]);
return (
<View style={{ alignItems: 'center' }}>
<Text>Click to enable BackgroundGeolocation</Text>
<Switch value={enabled} onValueChange={setEnabled} />
<Text style={{ fontFamily: 'monospace', fontSize: 12 }}>{location}</Text>
</View>
);
};
export default HelloWorld;
If I give setEnabled true in the Android emulator, it saves a post record on my server, but using the debug apk, if I enable it, nothing happens, that's all that's needed for it to work.
from react-native-background-geolocation.
Are you observing the plug-in logs in adb logcat?
see wiki “Debugging”.
You can’t develop with this plugin without observing the native device logs.
from react-native-background-geolocation.
This issue is stale because it has been open for 30 days with no activity.
from react-native-background-geolocation.
Even using BackgroundGeolocation.NOTIFICATION_PRIORITY_MIN it still emits sound, could the API not emit any sound at all?
notification: {
priority: BackgroundGeolocation.NOTIFICATION_PRIORITY_MIN,
title: 'Acompanhando sua localização',
text: 'Acompanhamos sua localização para enviar chamados de clientes próximos a você.',
},
from react-native-background-geolocation.
See api docs Config.debug
from react-native-background-geolocation.
Related Issues (20)
- Problem in handling permissions using onProviderChange. Two scenarios I am facing the issue
- `- BackgroundGeolocation is configured and ready` never logs true in the example code HOT 7
- User Arrow Direction on Android Often Misrepresents Users Walking/Facing Direction HOT 1
- Can not debug on android HOT 7
- Could not find any matches for com.transistorsoft:tslocationmanager-v21:+ as no versions of com.transistorsoft:tslocationmanager-v21 are available. HOT 11
- Do I need to buy the source code of this TSLocationManager? HOT 1
- How to use the TSLocationManager static library? HOT 1
- Background location didn't respond if I stops for certain minutes and then moving again HOT 5
- Discussion: Time-based Tracking and backgrounded app HOT 1
- LocationRequestService ANR on Android 14 HOT 10
- License Validation Issue After Upgrading React Native and react-native-background-geolocation (Android Only) HOT 3
- Battery Drain Issue (IOS) HOT 5
- Enter/exit geofence is not detected in trackingMode Geofences only (iOS) HOT 7
- Why is event optional?
- How do I initially (before reaching 200m) record positions accurately? HOT 1
- Continuous Location Tracking in Background for Android and iOS HOT 11
- Upgrading the plugin version failed on Android.
- Location Tracking Persists After Stopping in react-native-background-geolocation HOT 2
- Need to send the data simultaneously but it not sending the data every ten seconds once HOT 2
- We can't insert any coordinates in the server when the app is terminated (ANDROID) HOT 9
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 react-native-background-geolocation.