Closed mohanchalla closed 7 years ago
Do not use that Settings service found in the SampleApp
.
var bgGeoConfig = {
common: [
{ name: 'stopOnTerminate', group: 'application', value: false },
{ name: 'startOnBoot', group: 'application', value: false },
{ name: 'stopTimeout', group: 'activity recognition', value: 0 },
{ name: 'activityRecognitionInterval', group: 'activity recognition', value: 10000 },
{ name: 'debug', group: 'application', value: true },
{ name: 'deferTime', group: 'geolocation', value: 0 },
{ name: 'disableElasticity', group: 'geolocation', value: false },
{ name: 'locationTimeout', group: 'geolocation', value: 60 },
{ name: 'geofenceProximityRadius', group: 'geolocation', value: 0 },
{ name: 'geofenceInitialTriggerEntry', group: 'geolocation', value: true },
{ name: 'logLevel', group: 'geolocation', value: 5 },
{ name: 'desiredAccuracy', group: 'geolocation', value: 0 },
{ name: 'distanceFilter', group: 'application', value: 10 }
],
iOS: [
{ name: 'stationaryRadius', group: 'geolocation', value: 20 },
{ name: 'activityType', group: 'geolocation', value: 'AutomotiveNavigation' }
],
android: [
{ name: 'locationUpdateInterval', group: 'geolocation', value: 5000 },
{ name: 'fastestLocationUpdateInterval', group: 'geolocation', value: 1000 },
{ name: 'triggerActivities', group: 'activity recognition', value: 'running, walking, on_foot' },
{ name: 'forceReloadOnBoot', group: 'application', value: false },
{ name: 'forceReloadOnMotionChange', group: 'application', value: false },
{ name: 'forceReloadOnLocationChange', group: 'application', value: false },
{ name: 'forceReloadOnGeofence', group: 'application', value: false }
]
};
This is in support of the Settings Screen in the Demo app only. Your app will not expose the plugin's settings to the user.
The plugin itself does not require the SettingsService
found in the Demo app.
// 1. Add listeners
bgGeo.on('location', onLocation);
bgGeo.on('geofence', onGeofence);
bgGeo.on('motionchange', onMotionChange);
// 2. Configure
bgGeo.configure({
desiredAccuracy: 0,
distanceFilter: 50
}, function(state) {
// 3. Add geofence.
bgGeo.addGeofence(someGeofenceConfig);
if (!state.enabled) {
bgGeo.start();
}
});
If you want to test geofences in the SampleApp, you can add them manually by "long-press" on map. An "Add Geofence" popup will appear.
No I have created it as a local variable inside my service. I am not exposing this to the user as a setting option.
Ok I try to add the geofence in the sample app and I will try it.
Whatever, don't use it. That data-structure is designed for the SampleApp. It's not meant for you to use in your own apps.
Just make a simple config object
bgGeoConfig = {
desiredAccuracy: 0,
distanceFilter: 50,
.
.
.
};
OK I will reconfigure the object and I will try once again.
If you were sending this object to the plugin, of course it didn't work.
bgGeoConfig = {
common: [
{ name: 'stopOnTerminate', group: 'application', value: false },
{ name: 'startOnBoot', group: 'application', value: false },
{ name: 'stopTimeout', group: 'activity recognition', value: 0 },
{ name: 'activityRecognitionInterval', group: 'activity recognition', value: 10000 },
{ name: 'debug', group: 'application', value: true },
{ name: 'deferTime', group: 'geolocation', value: 0 },
{ name: 'disableElasticity', group: 'geolocation', value: false },
{ name: 'locationTimeout', group: 'geolocation', value: 60 },
{ name: 'geofenceProximityRadius', group: 'geolocation', value: 0 },
{ name: 'geofenceInitialTriggerEntry', group: 'geolocation', value: true },
{ name: 'logLevel', group: 'geolocation', value: 5 },
{ name: 'desiredAccuracy', group: 'geolocation', value: 0 },
{ name: 'distanceFilter', group: 'application', value: 10 }
],
iOS: [
{ name: 'stationaryRadius', group: 'geolocation', value: 20 },
{ name: 'activityType', group: 'geolocation', value: 'AutomotiveNavigation' }
],
android: [
{ name: 'locationUpdateInterval', group: 'geolocation', value: 5000 },
{ name: 'fastestLocationUpdateInterval', group: 'geolocation', value: 1000 },
{ name: 'triggerActivities', group: 'activity recognition', value: 'running, walking, on_foot' },
{ name: 'forceReloadOnBoot', group: 'application', value: false },
{ name: 'forceReloadOnMotionChange', group: 'application', value: false },
{ name: 'forceReloadOnLocationChange', group: 'application', value: false },
{ name: 'forceReloadOnGeofence', group: 'application', value: false }
]
};
bgGeo.configure(bgGeoConfig);
See Example in this repo's README.
I am iterating the object in the same way how you have done in the sample app. Based on platform dynamically I am concatenating the the array. I will reconfigure the object and check.
Don't worry about iterating platform-specific items. That data-structure is designed for the Settings screen, for showing applicable config options in the Settings screen to the user only.
You don't need to worry about parsing out platform-specific options to the plugin itself. Each platform ignores config options that don't apply to it.
You do not want to use anything in the Demo app's Settings system.
Is it possible to add the radius of 10 for testing purpose. You have already mentioned the radius less than 100 is not accurate.
No.
Is there any co-relation between geofenceProximityRadius and addGeofence method config "radius" parameter.
Identifier is not allowing me to add integer string value. This value I will use for the identification purpose on my server. Ex: var geoLocation = function (obj) { this.identifier = 'Home-1'; this.radius = obj.radius; this.latitude = obj.latitude; this.longitude = obj.longitude; this.notifyOnEntry = true; this.notifyOnDwell = true; this.notifyOnExit = true; this.loiteringDelay = 10000; };
There's nothing wrong with your identifier "Home-1"
Is it possible to add only Integers as an identifier or can I use # as delimiter for my id?
yes, but you might have to make sure it's a string.
this.identifier = new String(123).toString()
But seriously...why not just prefix it with something?? geofence_' + id
Ya fine I can use like in this way also. :)
I am using the plugin for attendance marking. is DWELL event is proper for entry event?
Dwell is Android only.
Dwell is like Entry with a delay.
Because I want user should stay at least some time in the configured area then only I will mark him as present. Which event should I need to consider? Can you please help how to handle this case?
There is no DWELL
for iOS.
If I close and reopen the app geofenceInitialTriggerEntry event has to fire. But it is not firing always.
With stopOnTerminate: false, the geofences do not stop being monitored when you terminate the app.
Why should you expect the initial trigger to fire just because you terminate and reboot the app?
Because If the user closes the app and once he enters into the fencing area after that If he open the app, I need to enable the SignIn button.
I do not understand your issue. I know nothing of your "signin" button.
An initialTriggerEntry can fire only once. If the current location is within some geofence, terminating the app with stopOnTerminate: false does not stop monitoring that geofence which already fired.
This perfectly logical.
I am integrating the attendance module with the plugin. If the user enters into the some location which is there with in the configured geofence. I will show "signIn" button. If he is out the the fence I will show "signout". For this If the app is closed and he opens the app with the fence then I should enable the button again. Until Unless he crosses the fences how many number of times he opens, I should always show the "signin" button.
It's not a matter of me understanding your app (that's not my responsibility), it's up to you to build your app within the constraints of the plugin's API.
You have made a faulty assumption about the nature of geofences with stopOnTerminate: false. An entry event can fire only once (until one exits and re-enters that geofence). Terminating the app with stopOnTerminate: false does not stop monitoring the geofence whose entry event has already fired.
I have already set the value as false for stopOnTerminate: false. But once I open the app it has to fire entry event? But not firing. I have even configured geofenceInitialTriggerEntry: true. And I roamed some places for exit event after that I entered into the geofence area, Opening the app It is not firing the event.
If I set stopOnTerminate: true, then it is firing the event whenever he opens the app. I am sorry my assumption was wrong.
Your Environment
cordova -v
):cordova platform ls
):Then I have created a geoLocation service and put all the method into it. on device ready I have called configure method document.addEventListener("deviceready", function () { bgGeo = window.BackgroundGeolocation; geoLocationService.configureBgGeo(); });
Once I get the server response then I will add the locations array geoLocationService.addGeoFences(locationArray); then immedialty I am calling below 2 statements geoLocationService.startGeoFences(); geoLocationService.startBGGeoService();