transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
655 stars 277 forks source link

Seeking freelance assistance #347

Closed EmpireState closed 6 years ago

EmpireState commented 6 years ago

Hi there.

I'm looking for someone with experience in implementing this plugin, to potentially help us implement it into an existing Ionic 1 app.

We've spent about 6 hours playing with the plugin, but cannot get it functioning the way we desire (not using persistent notifications for Android, we cannot seem to customise the local notification and there seems to be a "overlay detected" issue when the plugin is included on Android 6).

My core development team on the project is currently swamped and I cannot assign anyone full time to this task.

Would anyone be willing to help us out on a freelance basis to implement it for us?

Many thanks.

christocracy commented 6 years ago

The "overlay detected" is probably the plugin trying to show a Toast message that "License validation failure. Plugin is running in evaluation mode" in combination with the plugin attempting to show the "Allow Location Permission" popup.

I wouldn't worry about this, since the plugin won't attempt a Toast message on Android after you've purchased a license key.

christocracy commented 6 years ago

Post the Javascript code you're using to interact with the plugin.

EmpireState commented 6 years ago

Hi Chris.

Thank you for the assistance regarding the overlay detected.

I will post the JS here.

Ideally though, I'd love for someone who has experience with the plugin to be able to help us (instead of us having to learn as we go) with the implementation, which will be a very "vanilla" implementation.

We have around 40,000 points of interest we'd like to track but all that needs to happen is the local notification to display a customised message, when tapped open the app and display a popup which has 2 buttons, each button will trigger a state change in the app (which already exists).

So it would be great if someone could help us with that and allow my team to continue with other work.

Thanks anyone reading this.

EmpireState commented 6 years ago

Hi Chris.

Here is the code we've implemented for the geofence plugin:

var bgGeo = window.BackgroundGeolocation;
            console.log(bgGeo);

            bgGeo.on('geofence', function(geofence) {
                var location = geofence.location;
                var identifier = geofence.identifier;
                var action = geofence.action;

                console.log('A geofence has been crossed: ', identifier);
                console.log('ENTER or EXIT?: ', action);
                console.log(geofence);
                /*var promisePush = httpFactory.makeRequestNoLoading(
                         "sendPushGeofence",
                         localStorage.getItem("pushToken"),
                         "We have detected that you have arrived at a course.",
                         geofence.extras.zone_id,
                         geofence.extras.course_name,
                         geofence.extras.course_played
                    );*/

                var alertPopup = $ionicPopup.alert({
                    title: "Arrived at Course",
                    template: "We have detected that you have arrived at a course."
                });

            });

            NavigatorGeolocation.getCurrentPosition().then(function(ll) {

                var promiseGetCourses = httpFactory.makeRequestNoLoading("getAllCoursesGeofencing");
                promiseGetCourses.then(function(data) {
                    if (data.indexOf("Error") > -1) {

                    } else {
                        if (!Array.isArray(data)) {

                        } else {
                            if (data.length == 0) {

                            } else {
                                for (var i = 0; i < data.length; i++) {
                                    data[i].distanceFromCourse = Math.round(getDistanceFromLatLonInKm(ll.coords.latitude, ll.coords.longitude, data[i].Course_Latitude, data[i].Course_Longitude) * 100) / 100;
                                }
                                data.sort(dynamicSort("distanceFromCourse"));

                                var geofences = [];
                                for (var i = 0; i < data.length; i++) {
                                    //console.log(data[i]);
                                    geofences.push({
                                        identifier: data[i].Course_Name,
                                        radius: 500,
                                        latitude: data[i].Course_Latitude,
                                        longitude: data[i].Course_Longitude,
                                        notifyOnEntry: true,
                                        notifyOnExit: false,
                                        notifyOnDwell: false,
                                        loiteringDelay: 30000, // 30 seconds
                                        extras: { // Optional arbitrary meta-data
                                            zone_id: data[i].Course_ID,
                                            course_name: data[i].Course_Name,
                                            course_played: data[i].Courses_Played_ID
                                        }
                                    })

                                }
                                BackgroundGeolocation.configure({
                                    distanceFilter: 10,
                                    desiredAccuracy: 3,
                                    stopOnTerminate: false,
                                    startOnBoot: true,
                                    heartbeatInterval: 60,
                                    geofenceProximityRadius: 500,
                                    foregroundService: true,
                                    notificationText: "We have detected that you have arrived at a course."
                                }, function(state) {
                                    bgGeo.addGeofences(geofences.splice(0, 1000), function() {
                                        console.log("Successfully added geofence");
                                    }, function(error) {
                                        console.warn("Failed to add geofence", error);
                                    });
                                    BackgroundGeolocation.startGeofences(function(state) {
                                        console.log('- Geofence-only monitoring started', state.trackingMode);
                                    });
                                });
                            }
                        }
                    }
                }, function(error) {

                })
            });
christocracy commented 6 years ago

It's not a good idea to use cordova-plugin-geolocation in addition to background-geolocation because it creates a permissions tug-of-war. cordova-plugin-geolocation is going to request WhenInUse location permission if executed first (which it looks like will occur)

WhenInUse location permission will prevent geofences from firing. You need Always location permission for geofences to work.

The plugin has its own #getCurrentPosition method.

Anyway, you don't even have to surround the BackgroundGeolocation code with a call to getCurrentPosition: the first thing the plugin does when #start or #startGeofences is executed is ask "where am i?". You can capture those locations by simply listening to the location event.

EmpireState commented 6 years ago

Hi Chris.

Thank you. That was used to add the closest 1000 points as adding all 44 000 at the same time using the addGeoFences method took 20 minutes.

The biggest issue we're having though is that in Android Studio we can see a list of fences that have been crossed. It currently says "TSGeoFenceManager found 32/135 within 20000 metres" it then lists them all, but not a single local notification is triggered in the app. The on geofence event is never called.

Thanks, Ed.

christocracy commented 6 years ago
edwrede commented 6 years ago

GeofenceLogs.txt

Hi Chris.

Logs attached as requested.

The beeping is on and it does beep, but there's no local notification triggered.

Thanks,

christocracy commented 6 years ago

Why are you adding the same geofence multiple times? When you add a geofence with an idnetifier that already exists, the existing record is destroyed before the new one is added, as you can see in the logs.

  ✅  Observatory GC
05-26 09:18:10.875 INFO [GeofenceDAO create] 
  ✅  Observatory GC
05-26 09:18:10.885 INFO [GeofenceDAO destroy] 
  ✅  Observatory GC
05-26 09:18:10.889 INFO [GeofenceDAO create] 
  ✅  Observatory GC
05-26 09:18:10.898 INFO [GeofenceDAO destroy] 
  ✅  Observatory GC
05-26 09:18:10.905 INFO [GeofenceDAO create] 
  ✅  Observatory GC
05-26 09:18:10.915 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:10.921 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:10.929 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:10.936 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:10.944 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:10.952 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:10.961 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:10.967 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:10.975 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:10.980 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:10.989 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:10.994 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:11.002 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:11.008 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:11.016 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:11.021 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:11.033 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:11.039 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:11.049 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:11.056 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:11.064 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:11.069 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:11.078 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:11.088 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:11.096 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:11.106 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:11.114 INFO [GeofenceDAO destroy] 
  ✅  Houghton Golf Club
05-26 09:18:11.119 INFO [GeofenceDAO create] 
  ✅  Houghton Golf Club
05-26 09:18:11.127 INFO [GeofenceDAO destroy] 
  ✅  Parkview Golf Club
.
.
.
edwrede commented 6 years ago

Hi Chris.

We're not aware of why anything would duplicate, all the code we've written to interact with the plugin is above, what would be causing the duplicates?

Thank you for your help!

christocracy commented 6 years ago

This is the result of you calling #addGeofence / #addGeofences

edwrede commented 6 years ago

Hi Chris.

So are you implying that this is being added duplicate times into the array?

christocracy commented 6 years ago

the plugin is clearly saying that you are adding the same geofence multiple times.

you are clearly doing this:

bgGeo.addGeofences([{
  identifier: 'Houghton Golf Club',
  .
  .
  .
}, {
  identifier: 'Houghton Golf Club',
  .
  .
  .
}, {
  identifier: 'Houghton Golf Club',
  .
  .
  .
}, {
  identifier: 'Houghton Golf Club',
  .
  .
  .
}, {
  identifier: 'Houghton Golf Club',
  .
  .
  .
}, ...]);
edwrede commented 6 years ago

Hi Chris.

Just a single fence added now, beeps are there, but no local notifications, please see logs below:

05-30 07:48:28.795 INFO [BackgroundGeolocation ] ╔═════════════════════════════════════════════ ║ BackgroundGeolocation adapter ╠═════════════════════════════════════════════

05-30 07:48:28.816 DEBUG [a onCreate] CREATE TABLE IF NOT EXISTS locations (id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT '', timestamp TEXT, json TEXT, locked BOOLEAN); 05-30 07:48:28.822 DEBUG [a onCreate] CREATE TABLE IF NOT EXISTS geofences (id INTEGER PRIMARY KEY AUTOINCREMENT, identifier TEXT NOT NULL UNIQUE, latitude DOUBLE NOT NULL, sin_latitude DOUBLE NOT NULL, cos_latitude DOUBLE NOT NULL, longitude DOUBLE NOT NULL, sin_longitude DOUBLE NOT NULL, cos_longitude DOUBLE NOT NULL, radius DOUBLE NOT NULL, notifyOnEntry BOOLEAN NOT NULL DEFAULT 0, notifyOnExit BOOLEAN NOT NULL DEFAULT 0, notifyOnDwell BOOLEAN NOT NULL DEFAULT 0, loiteringDelay INTEGER NOT NULL DEFAULT 0, extras TEXT); 05-30 07:48:28.834 DEBUG [SQLiteLocationDAO dbh] ✅ Opened database 05-30 07:48:28.840 DEBUG [SQLiteLocationDAO prune] ℹ️ PRUNE -1 days 05-30 07:48:28.876 DEBUG [GeofenceDAO dbh] ✅ Opened database 05-30 07:48:28.891 INFO [BackgroundGeolocation ] 🔵 Connecting to GooglePlayServices... 05-30 07:48:28.926 INFO [Settings print] ╔═════════════════════════════════════════════ ║ BackgroundGeolocation Settings ╠═════════════════════════════════════════════ { "isMoving": false, "enabled": false, "odometer": 0, "schedulerEnabled": false, "trackingMode": "location", "distanceFilter": 10, "desiredAccuracy": 3, "desiredOdometerAccuracy": 100, "locationUpdateInterval": 1000, "fastestLocationUpdateInterval": 10000, "locationTimeout": 60, "deferTime": 0, "disableElasticity": false, "activityRecognitionInterval": 10000, "minimumActivityRecognitionConfidence": 75, "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking", "disableStopDetection": false, "stationaryRadius": 25, "stopTimeout": 0, "url": "", "method": "POST", "autoSync": true, "autoSyncThreshold": 0, "batchSync": false, "maxBatchSize": -1, "params": {}, "headers": {}, "extras": {}, "httpRootProperty": "location", "locationTemplate": "", "geofenceTemplate": "", "persist": true, "maxDaysToPersist": 1, "maxRecordsToPersist": -1, "locationsOrderDirection": "ASC", "geofenceProximityRadius": 20000, "geofenceInitialTriggerEntry": true, "stopOnTerminate": false, "startOnBoot": true, "heartbeatInterval": 60, "foregroundService": false, "notificationTitle": "", "notificationText": "GolfPlayed detected that you have arrived at a golf course.", "notificationColor": "", "notificationIcon": "", "forceReloadOnLocationChange": false, "forceReloadOnMotionChange": false, "forceReloadOnGeofence": false, "forceReloadOnBoot": false, "forceReloadOnHeartbeat": false, "forceReloadOnSchedule": false, "stopAfterElapsedMinutes": 0, "schedule": [], "configureUrl": "", "configureInterval": -1, "debug": true, "logLevel": 5, "logMaxDays": 3 }╚═════════════════════════════════════════════ 05-30 07:48:28.970 INFO [BackgroundGeolocation onConnected] ✅ Google Play Services: connected (version code:10240000) 05-30 07:48:29.024 INFO [BackgroundGeolocationService onStartCommand] ╔═════════════════════════════════════════════ ║ BackgroundGeolocation Service started ╠═════════════════════════════════════════════

05-30 07:48:29.034 INFO [BackgroundGeolocation requestActivityUpdates] 🎾 Start activity updates: 10000 05-30 07:48:29.049 INFO [BackgroundGeolocationService a] 🔵 setPace: null → false 05-30 07:48:29.056 INFO [BackgroundGeolocationService i] 🔴 Stop heartbeat 05-30 07:48:29.065 INFO [BackgroundGeolocationService a] 🎾 Start heartbeat (60) 05-30 07:48:29.109 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 05-30 07:48:29.140 DEBUG [BackgroundGeolocation isMainActivityActive] YES 05-30 07:48:29.417 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1001 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused -26,076370,28,232789 acc=22 et=+9d23h51m53s196ms]

05-30 07:48:29.435 INFO [TSLocationManager onSingleLocationResult] 🔵 Acquired motionchange position 05-30 07:48:29.445 DEBUG [TSLocationManager calculateMedianAccuracy] 22.116 05-30 07:48:29.458 INFO [SQLiteLocationDAO persist] ✅ INSERT: 11862da4-6edf-473d-9723-f562745f973b 05-30 07:49:01.133 INFO [Settings print] ╔═════════════════════════════════════════════ ║ BackgroundGeolocation Settings ╠═════════════════════════════════════════════ { "isMoving": false, "enabled": true, "odometer": 0, "schedulerEnabled": false, "trackingMode": "location", "distanceFilter": 10, "desiredAccuracy": 3, "desiredOdometerAccuracy": 100, "locationUpdateInterval": 1000, "fastestLocationUpdateInterval": 10000, "locationTimeout": 60, "deferTime": 0, "disableElasticity": false, "activityRecognitionInterval": 10000, "minimumActivityRecognitionConfidence": 75, "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking", "disableStopDetection": false, "stationaryRadius": 25, "stopTimeout": 0, "url": "", "method": "POST", "autoSync": true, "autoSyncThreshold": 0, "batchSync": false, "maxBatchSize": -1, "params": {}, "headers": {}, "extras": {}, "httpRootProperty": "location", "locationTemplate": "", "geofenceTemplate": "", "persist": true, "maxDaysToPersist": 1, "maxRecordsToPersist": -1, "locationsOrderDirection": "ASC", "geofenceProximityRadius": 20000, "geofenceInitialTriggerEntry": true, "stopOnTerminate": false, "startOnBoot": true, "heartbeatInterval": 60, "foregroundService": false, "notificationTitle": "", "notificationText": "GolfPlayed detected that you have arrived at a golf course.", "notificationColor": "", "notificationIcon": "", "forceReloadOnLocationChange": false, "forceReloadOnMotionChange": false, "forceReloadOnGeofence": false, "forceReloadOnBoot": false, "forceReloadOnHeartbeat": false, "forceReloadOnSchedule": false, "stopAfterElapsedMinutes": 0, "schedule": [], "configureUrl": "", "configureInterval": -1, "debug": true, "logLevel": 5, "logMaxDays": 3 }╚═════════════════════════════════════════════ 05-30 07:49:01.161 INFO [GeofenceDAO destroyAll] ✅
05-30 07:49:01.163 INFO [BackgroundGeolocationService i] 🔴 Stop heartbeat 05-30 07:49:01.182 DEBUG [a a] ╔═════════════════════════════════════════════ ║ TSGeofenceManager found 0/0 within 20000 meters ╠═════════════════════════════════════════════ ╚═════════════════════════════════════════════ 05-30 07:49:01.183 INFO [BackgroundGeolocationService a] 🔵 setPace: false → false 05-30 07:49:01.195 INFO [BackgroundGeolocationService a] 🎾 Start heartbeat (60) 05-30 07:49:01.204 INFO [BackgroundGeolocationService i] 🔴 Stop heartbeat 05-30 07:49:01.226 INFO [BackgroundGeolocationService a] 🎾 Start heartbeat (60) 05-30 07:49:01.322 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1003 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused -26,076370,28,232789 acc=22 et=+9d23h52m25s345ms]

05-30 07:49:01.337 INFO [TSLocationManager onSingleLocationResult] 🔵 Acquired motionchange position 05-30 07:49:01.342 DEBUG [TSLocationManager calculateMedianAccuracy] 22.0895 05-30 07:49:01.358 INFO [SQLiteLocationDAO persist] ✅ INSERT: 9514fba8-4940-4267-8480-b1ba232e7cf9 05-30 07:49:01.378 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1002 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused -26,076370,28,232789 acc=22 et=+9d23h52m25s345ms]

05-30 07:49:01.391 INFO [TSLocationManager onSingleLocationResult] 🔵 Acquired providerchange position 05-30 07:49:01.397 DEBUG [TSLocationManager calculateMedianAccuracy] 22.063 05-30 07:49:01.408 INFO [SQLiteLocationDAO persist] ✅ INSERT: 78540b55-d787-4221-b4c9-6043c5d43449 05-30 07:49:01.433 DEBUG [a a] ╔═════════════════════════════════════════════ ║ TSGeofenceManager found 0/0 within 20000 meters ╠═════════════════════════════════════════════ ╚═════════════════════════════════════════════ 05-30 07:49:01.600 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1003 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused -26,076370,28,232789 acc=22 et=+9d23h52m25s473ms]

05-30 07:49:01.609 WARN [TSLocationManager onSingleLocationResult] ⚠️ Failed to find SingleLocationRequest 05-30 07:49:01.636 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1002 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused -26,076370,28,232789 acc=22 et=+9d23h52m25s473ms]

05-30 07:49:01.644 WARN [TSLocationManager onSingleLocationResult] ⚠️ Failed to find SingleLocationRequest 05-30 07:49:02.628 WARN [BackgroundGeolocation start] ⚠️ Already started. Ignored 05-30 07:49:08.541 INFO [GeofenceDAO create] ✅ Avion Park GC 05-30 07:49:08.822 DEBUG [a a] ╔═════════════════════════════════════════════ ║ TSGeofenceManager found 1/1 within 20000 meters ╠═════════════════════════════════════════════ ╟─ 🎾 Avion Park GC ╚═════════════════════════════════════════════ 05-30 07:49:08.884 INFO [GeofenceService onHandleIntent] ╔═════════════════════════════════════════════ ║ Geofencing Event: ENTER ╠═════════════════════════════════════════════ ╟─ Avion Park GC ╚═════════════════════════════════════════════ 05-30 07:49:08.901 DEBUG [TSLocationManager calculateMedianAccuracy] 22.063 05-30 07:49:08.938 INFO [SQLiteLocationDAO persist] ✅ INSERT: 4a46dc10-47f3-4d31-85ce-6be770303090 05-30 07:49:09.026 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 05-30 07:49:09.039 DEBUG [BackgroundGeolocation isMainActivityActive] YES 05-30 07:49:50.602 INFO [Settings print] ╔═════════════════════════════════════════════ ║ BackgroundGeolocation Settings ╠═════════════════════════════════════════════ { "isMoving": false, "enabled": true, "odometer": 0, "schedulerEnabled": false, "trackingMode": "location", "distanceFilter": 10, "desiredAccuracy": 3, "desiredOdometerAccuracy": 100, "locationUpdateInterval": 1000, "fastestLocationUpdateInterval": 10000, "locationTimeout": 60, "deferTime": 0, "disableElasticity": false, "activityRecognitionInterval": 10000, "minimumActivityRecognitionConfidence": 75, "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking", "disableStopDetection": false, "stationaryRadius": 25, "stopTimeout": 0, "url": "", "method": "POST", "autoSync": true, "autoSyncThreshold": 0, "batchSync": false, "maxBatchSize": -1, "params": {}, "headers": {}, "extras": {}, "httpRootProperty": "location", "locationTemplate": "", "geofenceTemplate": "", "persist": true, "maxDaysToPersist": 1, "maxRecordsToPersist": -1, "locationsOrderDirection": "ASC", "geofenceProximityRadius": 20000, "geofenceInitialTriggerEntry": true, "stopOnTerminate": false, "startOnBoot": true, "heartbeatInterval": 60, "foregroundService": false, "notificationTitle": "", "notificationText": "GolfPlayed detected that you have arrived at a golf course.", "notificationColor": "", "notificationIcon": "", "forceReloadOnLocationChange": false, "forceReloadOnMotionChange": false, "forceReloadOnGeofence": false, "forceReloadOnBoot": false, "forceReloadOnHeartbeat": false, "forceReloadOnSchedule": false, "stopAfterElapsedMinutes": 0, "schedule": [], "configureUrl": "", "configureInterval": -1, "debug": true, "logLevel": 5, "logMaxDays": 3 }╚═════════════════════════════════════════════ 05-30 07:49:50.615 INFO [BackgroundGeolocationService i] 🔴 Stop heartbeat 05-30 07:49:50.620 DEBUG [a a] ╔═════════════════════════════════════════════ ║ TSGeofenceManager found 1/1 within 20000 meters ╠═════════════════════════════════════════════ ╟─ 🎾 Avion Park GC ╚═════════════════════════════════════════════ 05-30 07:49:50.625 INFO [GeofenceDAO destroyAll] ✅
05-30 07:49:50.627 INFO [BackgroundGeolocationService a] 🔵 setPace: false → false 05-30 07:49:50.654 INFO [BackgroundGeolocationService a] 🎾 Start heartbeat (60) 05-30 07:49:50.668 INFO [BackgroundGeolocationService i] 🔴 Stop heartbeat 05-30 07:49:50.705 INFO [BackgroundGeolocationService a] 🎾 Start heartbeat (60) 05-30 07:49:50.859 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1004 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused -26,076456,28,232786 acc=86 et=+9d23h53m14s847ms]

05-30 07:49:50.869 DEBUG [TSLocationManager calculateMedianAccuracy] 22.063 05-30 07:49:50.894 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1005 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused -26,076456,28,232786 acc=86 et=+9d23h53m14s847ms]

05-30 07:49:50.900 DEBUG [TSLocationManager calculateMedianAccuracy] 22.220215 05-30 07:49:50.917 DEBUG [a a] ╔═════════════════════════════════════════════ ║ TSGeofenceManager found 0/0 within 20000 meters ╠═════════════════════════════════════════════ ╟─ 🔴 Avion Park GC ╚═════════════════════════════════════════════ 05-30 07:49:51.095 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1004 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused -26,076456,28,232786 acc=86 et=+9d23h53m14s940ms]

05-30 07:49:51.105 DEBUG [TSLocationManager calculateMedianAccuracy] 22.377428 05-30 07:49:51.119 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 05-30 07:49:51.126 DEBUG [BackgroundGeolocation isMainActivityActive] YES 05-30 07:49:51.129 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1005 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused -26,076456,28,232786 acc=86 et=+9d23h53m14s940ms]

05-30 07:49:51.142 DEBUG [TSLocationManager calculateMedianAccuracy] 54.048214 05-30 07:49:53.946 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1004 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused -26,076423,28,232777 acc=4 et=+9d23h53m17s901ms alt=1653.1241033768504 vel=0.54590666 bear=47.0]

05-30 07:49:53.958 INFO [TSLocationManager onSingleLocationResult] 🔵 Acquired providerchange position 05-30 07:49:53.964 DEBUG [TSLocationManager calculateMedianAccuracy] 22.377428 05-30 07:49:53.976 INFO [SQLiteLocationDAO persist] ✅ INSERT: de10f5d5-fbe5-4219-895d-fd842c871d1f 05-30 07:49:53.986 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1005 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused -26,076423,28,232777 acc=4 et=+9d23h53m17s901ms alt=1653.1241033768504 vel=0.54590666 bear=47.0]

05-30 07:49:54.005 INFO [TSLocationManager onSingleLocationResult] 🔵 Acquired motionchange position 05-30 07:49:54.010 DEBUG [TSLocationManager calculateMedianAccuracy] 22.220215 05-30 07:49:54.034 INFO [SQLiteLocationDAO persist] ✅ INSERT: a6756fac-dd36-4036-8a91-46847d8b4524 05-30 07:49:54.035 INFO [LocationService onLocation] ℹ️ Location availability: true 05-30 07:49:54.059 INFO [LocationService onLocation] ℹ️ Location availability: true 05-30 07:49:54.110 WARN [BackgroundGeolocation start] ⚠️ Already started. Ignored 05-30 07:49:56.734 INFO [GeofenceDAO create] ✅ Avion Park GC 05-30 07:49:56.856 INFO [BackgroundGeolocationService a] 🔵 setPace: false → false 05-30 07:49:56.872 INFO [BackgroundGeolocationService i] 🔴 Stop heartbeat 05-30 07:49:56.888 INFO [BackgroundGeolocationService a] 🎾 Start heartbeat (60) 05-30 07:49:56.998 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1006 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused -26,076423,28,232777 acc=4 et=+9d23h53m20s982ms alt=1653.1241033768504 vel=0.54590666 bear=47.0]

05-30 07:49:57.000 DEBUG [a a] ╔═════════════════════════════════════════════ ║ TSGeofenceManager found 1/1 within 20000 meters ╠═════════════════════════════════════════════ ╟─ 🎾 Avion Park GC ╚═════════════════════════════════════════════ 05-30 07:49:57.017 INFO [TSLocationManager onSingleLocationResult] 🔵 Acquired motionchange position 05-30 07:49:57.029 DEBUG [TSLocationManager calculateMedianAccuracy] 22.063

christocracy commented 6 years ago

I know nothing about "local notifications". The plugin has nothing to do with that.

If you hear beep-beep-beep for a geofence trigger and your app is not terminated, then your JavaScript callback has been executed.

edwrede commented 6 years ago

Hi Chris.

Ummm wow have we been that far off the mark here? We've been expecting a notification to show once a geofence is crossed are you saying this will not happen?

Will the Javascript callback be executed when the app is closed?

christocracy commented 6 years ago

On Android, no JavaScript exists. Your entire Cordova app is destroyed when you terminate the app. See the docs for #stopOnTerminate.

Only the plugin's native service remains alive. -- Snet form Gmail Mobile

edwrede commented 6 years ago

How would we then show a notification to the user when they cross a geofence if the app is closed then?

christocracy commented 6 years ago

If you're providing an #url to the plugin and configuring autoSync:true, the plugin will have posted that geofence event to your server: send a Push notification from the server.

Or configure forceReloadOnGeofence: true to reboot your Cordova app when geofence triggers.

-- Snet form Gmail Mobile

edwrede commented 6 years ago

Thank you Chris, I was on the wrong page from the start then clearly, I'll look into that!

Any idea why the creation of the 40 000 geofences would take 20 minutes? If we can load them all that once we don't need anything in the background to update the geofences.

christocracy commented 6 years ago

The best you can do for adding geofences is to use the #addGeofences method (not #addGeofence for each).

You'll want to make sure you're not adding duplicate geofences, as well.

Other than that, the time is dependent upon the processor and ram of the device. -- Snet form Gmail Mobile

christocracy commented 6 years ago

And for a true sense of the time to #addGeofences, you'll want to set logLevel: 0 since logging for those geofences will artificially inflate the time.

-- Snet form Gmail Mobile

edwrede commented 6 years ago

Hi Chris.

Thanks we're making much better progress now.

The one issue we've seen on Android, adding 40,000 fences (via the addgeofences method) is that sometimes the app displays a "app is not responding message".

Is there a way around this?

Thanks.

christocracy commented 6 years ago

I've been fighting this "app is not responding" (technically referred to as an ANR) all day.

The plugin is executing all its actions on a background thread so isn't loading the UI thread at all. I don't understand why this ANR is happening.

christocracy commented 6 years ago

Oh, I've found where the issue is. You'll find if you insert geofences while the plugin is #stopped, you won't get an ANR. I think I can fix this.

christocracy commented 6 years ago

It's causes by the heartbeat event, which fires on the main thread. The heartbeat event checks to see if there's any records in the database to HTTP sync. However, since the database handle is locked by the thread inserting the geofences, the attempt to get the database count in the heartbeat event blocks the UI thread, causing the ANR.

This should be easy to fix.

edwrede commented 6 years ago

Thanks Chris, looking forward to the fixed update then!

Thanks again!

christocracy commented 6 years ago

Latest fixes always appear in the paid version first. This free repo contains only the latest stable release of the premium version.

The free version here receives updates about every 3 months.

edwrede commented 6 years ago

Hi Chris.

Hmm okay, so you're suggesting we buy the plugin assuming the fix we need has been made even though we cannot test it first?

Thanks!

christocracy commented 6 years ago

That is correct.

On Wed, Jun 7, 2017 at 3:00 AM edwrede notifications@github.com wrote:

Hi Chris.

Hmm okay, so you're suggesting we buy the plugin assuming the fix we need has been made even though we cannot test it first?

Thanks!

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/transistorsoft/cordova-background-geolocation-lt/issues/347#issuecomment-306705374, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA6l3_nN0AEwEysr70m4mWaarN4Q6t5ks5sBkqhgaJpZM4NhqGA .

-- Snet form Gmail Mobile

christocracy commented 6 years ago

This fixes a mere edge case when adding unusually large set of geofences. The plugin does not fail to add those geofences. The fix is a simple matter.

You can carry on to test the core tracking features on the assumption there will be no ANR pop up in the paid version.