-
Notifications
You must be signed in to change notification settings - Fork 425
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
Need Help when app is closed #2187
Comments
The issue template is required, not optional: Your Environment
PASTE_YOUR_CODE_HERE Expected BehaviorActual BehaviorSteps to ReproduceContextDebug logsLogs
|
Plugin version: 4.1.1 React.useEffect(() => {
BackgroundGeolocation.logger
.getLog()
.then(log => {
console.log('log', log);
})
.catch(error => {
console.error('Error getting log:', error);
});
BackgroundGeolocation.deviceSettings.showIgnoreBatteryOptimizations();
BackgroundGeolocation.onGeofence(geofence => {
console.log('Geofence event:', geofence);
});
BackgroundGeolocation.onActivityChange(s =>
console.log('onActivityChange', s),
);
BackgroundGeolocation.onNotificationAction(button => {
console.log('[onNotificationAction]', button);
});
// Listen to location updates
BackgroundGeolocation.onLocation(handleLocationUpdate, error => {
console.log('[BackgroundGeolocation] location error:', error);
});
BackgroundGeolocation.onMotionChange(location => {
console.log('onMotionChange', location);
});
initBackgroundFetch();
initBackgroundGeolocation();
// // Cleanup on unmount
// return () => {
// // BackgroundGeolocation.removeListeners();
// };
}, []);
const initBackgroundGeolocation = async () => {
const token =
await BackgroundGeolocation.findOrCreateTransistorAuthorizationToken(
'phpoets',
'Sameer98700',
'https://tracker.transistorsoft.com',
);
// Configure BackgroundGeolocation
BackgroundGeolocation.ready({
reset: true,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 50,
stationaryRadius: 50,
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE, // Enable verbose logging
debug: true,
activityRecognitionInterval: 1000,
stopTimeout: 60,
disableMotionActivityUpdates: false,
disableElasticity: true,
startOnBoot: true,
heartbeatInterval: 60,
enableHeadless: true,
stopOnTerminate: false,
desiredOdometerAccuracy: 10,
allowIdenticalLocations: false,
autoSync: true,
autoSyncThreshold: 0,
batchSync: true,
maxBatchSize: 10,
maxDaysToPersist: 2,
foregroundService: true,
locationAuthorizationRequest: 'Always',
geofenceInitialTriggerEntry: true,
geofenceModeHighAccuracy: true,
notification: {
title: 'Location Tracking',
text: 'Tracking location in the background',
color: '#ff00ff',
},
}).then(state => {
// Start the Scheduler
BackgroundGeolocation.startSchedule();
});
};
// Listen to #onSchedule events:
BackgroundGeolocation.onSchedule(state => {
let enabled = state.enabled;
console.log('[onSchedule] - enabled? ', enabled);
});
// Or modify the schedule with usual #setConfig method
BackgroundGeolocation.setConfig({
schedule: [
'1-7 9:00-10:00',
'1-7 11:00-12:00',
'1-7 13:41-13:44',
'1-7 15:00-16:00',
'1-7 17:00-18:00',
'2,4,6 19:00-22:00',
],
});
// Add a geofence.
BackgroundGeolocation.addGeofence({
notifyOnExit: true,
radius: 50,
identifier: 'ZONE_OF_INTEREST',
latitude: location?.latitude,
longitude: location?.longitude,
});
const initBackgroundFetch = async () => {
BackgroundFetch.configure(
{
minimumFetchInterval: 15,
enableHeadless: true,
stopOnTerminate: false,
},
async taskId => {
console.log('taskId', taskId);
const location = await BackgroundGeolocation.getCurrentPosition({
extras: {
event: 'background-fetch',
},
maximumAge: 10000,
persist: true,
timeout: 30,
samples: 2,
});
handleLocationUpdate(location);
BackgroundFetch.finish(taskId);
},
async taskId => {
console.log('[BackgroundFetch] TIMEOUT:', taskId);
BackgroundFetch.finish(taskId);
},
);
}; |
You're using version
For Android, see API docs
The plugin will automatically resume tracking after app terminate when the devices moves at least 200 meters. You will hear Debug SoundFX to show it's working.
The minimum geofence radius is |
Also, your code is wrong. // Configure BackgroundGeolocation
BackgroundGeolocation.ready({
.
.
.
}).then(state => {
// Start the Scheduler
BackgroundGeolocation.startSchedule();
});
};
// Listen to #onSchedule events:
BackgroundGeolocation.onSchedule(state => {
let enabled = state.enabled;
console.log('[onSchedule] - enabled? ', enabled);
});
// Or modify the schedule with usual #setConfig method
BackgroundGeolocation.setConfig({
schedule: [
'1-7 9:00-10:00',
'1-7 11:00-12:00',
'1-7 13:41-13:44',
'1-7 15:00-16:00',
'1-7 17:00-18:00',
'2,4,6 19:00-22:00',
],
}); You're calling Plugin method calls take an unknown amount of time to execute. That's why they return a BackgroundGeolocation.ready({
.
.
.
schedule: [
'1-7 9:00-10:00',
'1-7 11:00-12:00',
'1-7 13:41-13:44',
'1-7 15:00-16:00',
'1-7 17:00-18:00',
'2,4,6 19:00-22:00',
]
}).then((state) => {
// Here, the Promise of the .ready method has RESOLVED. Only now has the Config been applied.
BackgroundGeolocation.startSchedule()
});
// It is unknown if the Promise of the .ready method has resolved yet.
// If .ready(config) resolves first, you will be calling `.startSchedule()` with an empty schedule.
BackgroundGeolocation.setConfig(config); |
I have a feeling you're just copy/pasting code with no understanding of how it actually works. Also see Wiki "Debugging" and "Philosophy of Operation". BackgroundGeolocation.logger
.getLog()
.then(log => {
console.log('log', log);
})
.catch(error => {
console.error('Error getting log:', error);
}); It's pretty crazy how you console.log the plugin's |
Hey,
I updated to the latest version 4.17.4 in Android, and it is working fine
but in ios BackgroundGeoLocation.onLocation function does not fire when the
app is closed.
previously version 4.1.1 BackgroundGeoLocation.onLocation worked in ios
Note -- I added in the index.js file
… Message ID:
<transistorsoft/react-native-background-geolocation/issues/2187/2437813071
@github.com>
|
You added what in the |
BackgroundGeoLocation.onLocation
…On Mon, 28 Oct 2024 at 7:24 PM, Chris Scott ***@***.***> wrote:
Note -- I added in the index.js file
You added *what* in the index.js file?
—
Reply to this email directly, view it on GitHub
<#2187 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3DEOKRAGCI2TTWZSGIOYETZ5Y62BAVCNFSM6AAAAABQRC5MT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBRGY2TQMJQG4>
.
You are receiving this because you authored the thread.Message ID:
<transistorsoft/react-native-background-geolocation/issues/2187/2441658107
@github.com>
|
For the Android terminated state, see API docs |
For iOS, there's no such thing as "headless". You must ensure your app calls |
This is for android
what we do for ios?
…On Mon, 28 Oct 2024 at 8:11 PM, Chris Scott ***@***.***> wrote:
.onLocation does *not* belong in index.js. Remove it from there!
For the Android *terminated* state, see API docs Config.enabledHeadless.
—
Reply to this email directly, view it on GitHub
<#2187 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3DEOKRI5AN4VRLRX2SLR4TZ5ZEKHAVCNFSM6AAAAABQRC5MT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBRG44DGNZYGM>
.
You are receiving this because you authored the thread.Message ID:
<transistorsoft/react-native-background-geolocation/issues/2187/2441783783
@github.com>
|
iOS will automatically relaunch your app in the background when the device is detected to be moving, just as if launched by the user from the foreground. |
Yes I know but when app is terminated then how to show updated location
logs and which function provide me a logs
…On Mon, 28 Oct 2024 at 8:15 PM, Chris Scott ***@***.***> wrote:
iOS terminated behaviour is easily tested in the iOS simulated with
location simulated with *Freeway Drive*.
Screenshot.2024-10-28.at.10.44.35.AM.png (view on web)
<https://github.com/user-attachments/assets/9b7e461d-d937-44ef-9275-11ca93ed17ab>
—
Reply to this email directly, view it on GitHub
<#2187 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3DEOKUHMFKEKXNPPL6GL73Z5ZEYNAVCNFSM6AAAAABQRC5MT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBRG44TGOBYGE>
.
You are receiving this because you authored the thread.Message ID:
<transistorsoft/react-native-background-geolocation/issues/2187/2441793881
@github.com>
|
on iOS, every recorded location is sent to your |
Search API docs "emailLog" |
This is not working for me
…On Mon, 28 Oct 2024 at 8:21 PM, Chris Scott ***@***.***> wrote:
then how to show updated location
on iOS, every recorded location is sent to your .onLocation
event-listener.
—
Reply to this email directly, view it on GitHub
<#2187 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3DEOKVMQH4UGA7Z7MQ24TDZ5ZFNXAVCNFSM6AAAAABQRC5MT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBRHAYTAMJWGM>
.
You are receiving this because you authored the thread.Message ID:
<transistorsoft/react-native-background-geolocation/issues/2187/2441810163
@github.com>
|
"what" is not working for you? |
How it works?
…On Mon, 28 Oct 2024 at 8:21 PM, Chris Scott ***@***.***> wrote:
Search API docs "emailLog"
—
Reply to this email directly, view it on GitHub
<#2187 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3DEOKUEEBLBOEPVQQZWIS3Z5ZFPHAVCNFSM6AAAAABQRC5MT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBRHAYTCNZRGY>
.
You are receiving this because you authored the thread.Message ID:
<transistorsoft/react-native-background-geolocation/issues/2187/2441811716
@github.com>
|
How "what" works? |
Are you testing your app in the iOS Simulator, simulating location with Freeway Drive? |
.onLocation not working when app is terminated. It only works on foreground
…On Mon, 28 Oct 2024 at 8:24 PM, Chris Scott ***@***.***> wrote:
"what" is not working for you?
—
Reply to this email directly, view it on GitHub
<#2187 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3DEOKWZMAQZHILP2ASRHE3Z5ZFYTAVCNFSM6AAAAABQRC5MT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBRHAYTQOBWGM>
.
You are receiving this because you authored the thread.Message ID:
<transistorsoft/react-native-background-geolocation/issues/2187/2441818863
@github.com>
|
Yes
…On Mon, 28 Oct 2024 at 20:25, Chris Scott ***@***.***> wrote:
Are you testing your app in the iOS Simulator, simulating location with *Freeway
Drive*?
—
Reply to this email directly, view it on GitHub
<#2187 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3DEOKVKZQ6N7I4DYBJTU43Z5ZF6LAVCNFSM6AAAAABQRC5MT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBRHAZDGNJZGI>
.
You are receiving this because you authored the thread.Message ID:
<transistorsoft/react-native-background-geolocation/issues/2187/2441823592
@github.com>
|
Show me logs of your app launching in the iOS simulator. |
Ok wait
…On Mon, 28 Oct 2024 at 22:00, Chris Scott ***@***.***> wrote:
Show me logs of your app launching in the iOS simulator.
—
Reply to this email directly, view it on GitHub
<#2187 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3DEOKRJKML7EA7US7GDH3LZ5ZRD3AVCNFSM6AAAAABQRC5MT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBSGA3TAOJXHA>
.
You are receiving this because you authored the thread.Message ID:
<transistorsoft/react-native-background-geolocation/issues/2187/2442070978
@github.com>
|
Hi,
We are trying to integrate your React Native Background Geolocation Package in our project and facing below challenges -
When the user app is closed, then we need to send the current location of the user from android and iOS. We are only able to track the user but not able to receive the current location. Can you please guide which package or function we need to use in react native background geolocation package.
When the user is ideal and the app is closed then we are unable to track that user. After that once the user starts moving then also we are unable to track as the starting user was unable to track. Please guide me on how to solve this issue.
We added a geo facing function, when the user is away from the 50 meter radius then when the app is closed, we are unable to receive the log. But as soon as the app is open, we receive the logs. Need solution for this as well.
Facing both above uses majorly on iOS devices.
Kindly help us with the above query and give a solution to it.
The text was updated successfully, but these errors were encountered: