Closed dda-vasavi-yerapotula closed 7 years ago
The plugin isn't responsible for "notifications"
If you're performing stuff in a Javascript callback, the MainActivity
(where your Javascript lives) is necessarily terminated when user terminates an Android applications. Only the plugin's native background-services remains alive and tracking (and optionally posting to your server if you configured an #url
.
I suggest you switch to using server Push notifications. You might also explore the plugin's forceReload configuration params.
There's nothing the plugin can do to prevent the MainActivity
(where your Javascript lives) from terminating.
Thanks for the response Chris. I am talking about the event geofence crossing also not getting fired. if that event fires our notification will work. we are able to get this working in Iphone and it is just an issue with android. does the foreReload option helps to resolve this issue?
I do not see any reference to an issue about geofences being fired. Do you have a link to this thread?
i have attached my code and it has all events we are using and config file
All your Javascript is terminated when app is terminated. None of your Javascript callbacks will execute.
Try using forceReloadOnGeofence: true
FYI: Do NOT execute any API method (aside from adding event-listeners until the callback
to #configure
executes:
// NO! Do NOT execute #getCurrentPosition here! Plugin is not ready to use until callback to #configure executes
$cordovaGeolocation.getCurrentPosition(options).then(function(position) {
var myLatitude = Math.round(position.coords.latitude * 10000000) / 10000000;
var myLongitude = Math.round(position.coords.longitude * 10000000) / 10000000;
if (config == undefined) {
config = $rootScope.appConfig;
}
var configuration = config.GeoFence;
BackgroundGeolocation.configure(configuration, function(state) {
/////////////////////////
// PLUGIN IS NOW READY TO USE.
//////////////////////////////////////////////////////////////////////
});
Oh...hold on. You're using $cordovaGeolocation
. Anyway, that plugin is completely unnecessary when using background-geolocation
. In fact, in can cause permissions issues on iOS.
background-geolocation
has its own perfectly ok #getCurrentPosition
method.
Thanks Chris. I will follow up with my tesm
I have installed BG Geolocation app in my android phone and noticed the same problem. we are getting geofence exit message when application is in foreground. when I killed the application didn't get any notification. There is only message I always see on the lock screen that says location service activated. Any thoughts on this?
Logs please. The sample app has an [email log] button in settings screen
I just got the below from the log
{
"isMoving": false,
"distanceFilter": 20,
"desiredAccuracy": 0,
"locationUpdateInterval": 1000,
"fastestLocationUpdateInterval": 1000,
"geofenceProximityRadius": 250,
"locationTimeout": 60,
"activityRecognitionInterval": 1000,
"minimumActivityRecognitionConfidence": 75,
"triggerActivities": "in_vehicle, on_bicycle, running, walking, on_foot",
"disableStopDetection": false,
"stationaryRadius": 25,
"stopTimeout": 0,
"debug": true,
"stopAfterElapsedMinutes": 0,
"stopOnTerminate": false,
"startOnBoot": true,
"forceReloadOnLocationChange": false,
"forceReloadOnMotionChange": false,
"forceReloadOnGeofence": false,
"forceReloadOnBoot": false,
"forceReloadOnHeartbeat": false,
"maxDaysToPersist": 1,
"maxRecordsToPersist": -1,
"url": "http:\/\/posttestserver.com\/post.php?dir=ionic-cordova-background-geolocation",
"method": "POST",
"autoSync": true,
"autoSyncThreshold": 0,
"batchSync": false,
"params": {
"device": {
"available": true,
"platform": "Android",
"version": "7.0",
"uuid": "5495e78c33a9ad13",
"cordova": "5.2.2",
"model": "SAMSUNG-SM-G930A",
"manufacturer": "samsung",
"isVirtual": false,
"serial": "1a9b30d0"
}
},
"license": "
Those are not logs. That is a config object.
I clicked on send log button and selected email and this is what it send
Did you build it yourself or install from play store?
-- Snet form Gmail Mobile
This is recently bought android last week and we bought this phone exclusively for geofence testing
From playstore
in Android
I don't know how you managed to set this:
"geofenceProximityRadius": 250,
That shouldn't be possible from the UI. The minimum available selection is 1000.
Set that to 1000
I see many options in this geofenceproximityradius ( 0, 100, 250, 500, 1000, 2500, 5000, 10000) and I am able to change it
wifi enabled and SIm card activated as I am getting geofence exit when application is in foreground. where do I see location services (set to high accuracy)?
you installed this version from play store (see screenshot)?
https://play.google.com/store/apps/details?id=com.transistorsoft.backgroundgeolocation.ionic2
I actually installed the below one as we are using just Ionic (not ionic 2) https://play.google.com/store/apps/details?id=com.transistorsoft.background_geolocation.ionic
The first link didn't work with my phone and I have deleted it
The same version works perfectly in our mac and Iphone and it is only problem with new android phone
we are close to purchase this product just need to get it work when the app is killed in android
Delete it. It doesn't matter if you're using Ionic 1. That old sample app is garbage and using a very OLD version of the plugin.
Only the Ionic 2 version uses the latest version of the plugin.
Install the Ionic 2 version.
but the new app I installed didn't work in my phone. i didn't get any message like geofence crossed and didn't even let me change settings
Show me a screen shot of the settings screen of new app. How is it you can't change settings?
Ok I have installed new app and was able to change settings when I added fence. However I have to change it to trackingmode geofence and it changed it back to trackingmode location. let me drive tomorrow and i will let you know. Thanks for your time
I just installed the Ionic 2 version from play store on 3 devices here with no issue.
But we are using Ionic 1 version. Do you have any detailed documentation on the flow of events that supports ionic 1 other than docs link in the website? App installs fine and I didn't find it working but will check again tomorrow morning
and it changed it back to trackingmode location
This is merely a bug in the UI code for the Switch. The toggle handler is always calling bgGeo.start()
It should be checking trackingMode
and:
if (trackingMode === 'location') {
bgGeo.start();
} else {
bgGeo.startGeofences();
}
But we are using Ionic 1 version.
It doesn't matter. This is NOT an Ionic plugin -- it's a Cordova plugin. You can make your app with pure, vanilla Javascript -- what you build your UI with does not matter. Ionic is a UI FRAMEWORK. The plugin doesn't care about UI.
The plugin emits events only.
Is this the code base for the app you suggested just now
https://github.com/transistorsoft/cordova-background-geolocation-lt
You should not use the SampleApp as a guide of how to use the plugin. The SampleApp has a whole bunch of complexity involving the Settings screen. Obviously you won't make an app with a settings screen around the plugin like that.
Using the plugin is all about listening to events.
// 1. Listen to events
bgGeo.on('location', onLocation, onLocationFailure);
bgGeo.on('motionchange', onMotionChange);
bgGeo.on('providerchange', onProviderChange);
.
.
.
// 2. Configure the plugin.
bgGeo.configure({
desiredAccuracy: 0, // <-- Config params
distanceFilter: 50
}, function(state) { // <-- Current state provided to #configure callback
// 3. Start tracking
console.log('BackgroundGeolocation is configured and ready to use');
if (!state.enabled) {
bgGeo.start(function() {
console.log('- BackgroundGeolocation tracking started');
});
}
});
Is this the code base for the app you suggested just now https://github.com/transistorsoft/cordova-background-geolocation-lt
No, that is the plugin itself. In the README is a link to the Sample App
I suggest you carefully read all the README of the plugin. It's not that long.
I drove like 15 miles but didn't get any popup/notification from the BG Geo2 app. I also added fence with enter and exit options but didn't get any message and I do see the object changing in the map and it draws the route but no popup messages.
Moreover we created POC app to demonstrate this. i created apk file out of this code and tested in my samsung phone and notice the same issue. Can you please take a look at it and I am attaching my code here code.zip
Also the log is here
{ "isMoving": false, "enabled": true, "odometer": 23783.475, "schedulerEnabled": false, "trackingMode": "location", "distanceFilter": 10, "desiredAccuracy": 0, "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": "http:\/\/192.168.11.100:8080\/locations", "method": "POST", "autoSync": false, "autoSyncThreshold": 0, "batchSync": false, "maxBatchSize": -1, "params": { "device": { "model": "SAMSUNG-SM-G930A", "platform": "Android", "uuid": "5495e78c33a9ad13", "version": "7.0", "manufacturer": "samsung" } }, "headers": {}, "extras": {}, "httpRootProperty": "location", "locationTemplate": "", "geofenceTemplate": "", "persist": true, "maxDaysToPersist": 1, "maxRecordsToPersist": -1, "geofenceProximityRadius": 1000, "geofenceInitialTriggerEntry": true, "stopOnTerminate": false, "startOnBoot": true, "heartbeatInterval": -1, "foregroundService": true, "notificationTitle": "", "notificationText": "Location Service activated", "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
What radius of geofence are you creating?
On Thu, May 18, 2017 at 8:48 AM, dda-vasavi-yerapotula < notifications@github.com> wrote:
I drove like 15 miles but didn't get any popup/notification from the BG Geo2 app. I also added fence with enter and exit options but didn't get any message and I do see the object changing in the map and it draws the route but no popup messages.
Moreover we created POC app to demonstrate this. i created apk file out of this code and tested in my samsung phone and notice the same issue. Can you please take a look at it and I am attaching my code here code.zip https://github.com/transistorsoft/cordova-background-geolocation-lt/files/1010888/code.zip [image: plugins_used] https://cloud.githubusercontent.com/assets/21060971/26202825/c80660b0-3ba6-11e7-847f-45426842f144.PNG
— 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/343#issuecomment-302393732, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA6l3xYsNN0x8vfRbGUXAv__HHajFrGks5r7D43gaJpZM4NdKK- .
-- Chris Scott Transistor Software http://www.transistorsoft.com
POC project - 200 meters
have you tried the app in SAMSUNG-SM-G930A?
the details should be in attached code as well
I develop strictly on Nexus devices because it's the flagship Android device, where APIs operate as documented.
This could be Samsung's Smart Manager messing things up.
However, I plan to purchase a Samsung G7 edge today.
Ok Chris. I am the technical lead for this project and need to give my analysis by tomorrow so that we can purchase this product. This is our ambitious project and my team is working on this for last 2 months :-) and also happy to see things working in IPhone. Are you going to check it in Samsung and let us know how it goes. Thanks for the prompt reply
Here's my first boot of my SampleApp, a short 3km round-trip walk through 4 geofences. Looks good to me.
location markers off (showing geofence transitions)
Chris, what settings did you do to get these fences. I am trying now and cannot get it to work and I am using fake GPS free drive with BG geo app and see map is changing. Also did you get fence exited popup?
Android Geofences don't fire with mocked locations, unfortunately. They only fire with real field-testing.
This above field-test was done with location tracking-mode (not geofences only). Mostly default settings.
{
"isMoving": false,
"enabled": true,
"odometer": 2976.1577,
"schedulerEnabled": false,
"trackingMode": "location",
"distanceFilter": 50,
"desiredAccuracy": 0,
"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": 1,
"url": "http:\/\/192.168.11.200:9000\/locations",
"method": "POST",
"autoSync": false,
"autoSyncThreshold": 0,
"batchSync": false,
"maxBatchSize": -1,
"params": {
"device": {
"model": "SAMSUNG-SM-G930A",
"platform": "Android",
"uuid": "ad94b1f488b08f2c",
"version": "6.0.1",
"manufacturer": "samsung",
"framework": "Cordova"
}
},
"headers": {},
"extras": {},
"httpRootProperty": "location",
"locationTemplate": "",
"geofenceTemplate": "",
"persist": true,
"maxDaysToPersist": 1,
"maxRecordsToPersist": -1,
"locationsOrderDirection": "ASC",
"geofenceProximityRadius": 1000,
"geofenceInitialTriggerEntry": true,
"stopOnTerminate": false,
"startOnBoot": true,
"heartbeatInterval": -1,
"foregroundService": true,
"notificationTitle": "",
"notificationText": "Location Service activated",
"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
}
Your Environment
Plugin version: latest plugin downloaded from this website month back
Platform: iOS or Android (Android)
OS version:
Device manufacturer / model: Samsung Galaxy - SM -G930 code.zip
Cordova version (
cordova -v
): 6.5.0Cordova platform version (
cordova platform ls
):Plugin config - please see the attachment
Expected Behavior
Need to get notifications when the application is foreground, background or even it is killed
Actual Behavior
when the application gets killed or it is in background don't receive notifications when geofence is crossed in Android and works fine in Iphone
Steps to Reproduce
1. 2. 3. 4.
Context
Debug logs