Closed jin-chong closed 3 years ago
Geofence events are flaky with mocked location.
It’s a well-known problem, google it: “android geofence mock location”.
Best way to test geofences is on real device in real world testing.
Hi @christocracy Thanks for your reply. I don't know, but it shows me inconsistent behaviour on android. It stops working on background. and I cannot see foreground notification bar. My setup is same with original post. I records screen with app operation and logs. Could you please watch it and give me some advice? I really wanna use it, but I'm so desperate. video link - https://1drv.ms/v/s!AjdU6cu7sA3BuwYPNeJnAw_TFNFK?e=mF3dhl
Are you observing the plugin logs? See wiki Debugging.
Yes. you can watch I'm collecting by adb logcat from the above screen record. As you can watch from screen record, plugin logs does not show any geofence change when application runs on background.
Ok, @christocracy . I figured out what happens.
On iOS, BackgroundGeolocation.startGeofences() is working on background as expected. But on Android, startGeofences() does not work on background.
I think on Background Android, Location event needs for Geofence event.
To trigger geofence event on background Android,
Could you please confirm it? and any plan to get it fixed?
If I called startGeofences(), I should call getCurrentPosition at heartbeat event
No
Or I should call BackgroundGeolocation.start()
No.
Hi @christocracy , I've tested it with Config.geofenceModeHighAccuracy true/false both. same results. On Android emulator, startGeofences() does not fire geofence event on background. However when I call getCurrentPosition at heartbeat event, App receives geofence event following location event.
the below is my configuration and then I run startGeofences(). And I uploaded the screen record. please watch it. https://1drv.ms/u/s!AjdU6cu7sA3Buwd0PpBbpBfEBXUU?e=9WZ6RQ
{
locationAuthorizationRequest: 'Always', // Geofence monitoring requires the user authorize locationAuthorizationRequest Always
distanceFilter: 10,
stopOnTerminate: false,
startOnBoot: true,
heartbeatInterval: 60,
// >> for iOS
preventSuspend: true, // iOs
locationAuthorizationAlert: {
titleWhenNotEnabled: "location-services not enabled",
titleWhenOff: "location-services OFF",
instructions: "You must enable 'Always' in location-services",
cancelButton: "Cancel",
settingsButton: "Settings"
},
// << for iOS
// >> android
enableHeadless: true, // android
foregroundService: true, // android
notification: {
title: 'App active',
text: 'Hello.',
// sticky: true,
// priority: BackgroundGeolocation.NOTIFICATION_PRIORITY_HIGH,
},
// << android
debug: Platform.OS === 'android', // todo: how to enable disable it by compile option?
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE, // todo: how to enable disable it by compile option?
geofenceInitialTriggerEntry: true,
geofenceModeHighAccuracy: true,
},```
Thanks.
You can’t reliably test geofences in emulator.
You need to do real world testing on a real device.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.
Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.
Definitely I will purchase it for Android. But I should show it to the customer before purchase. Please help me.
Your Environment
react-native -v
): 4.12.0async componentDidMount() { // Step 2: #configure: BackgroundGeolocation.ready( { locationAuthorizationRequest: 'Always', distanceFilter: 10, stopOnTerminate: false, startOnBoot: true, heartbeatInterval: 60, enableHeadless: true, // android foregroundService: true, // android notification: { title: 'My App', text: 'AAA', }, // << android debug: Platform.OS === 'android', // todo: how to enable disable it by compile option? logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE, // todo: how to enable disable it by compile option?
} ... }