Closed HamzaLJ closed 6 years ago
This is not the Mauron85 version. Mauron85 is a fork from over 3 years ago of my original open source project.
So I need now to install the latest using cordova plugin add cordova-background-geolocation-lt
? Even purchase the license to make it work ?
iOS is free. Android requires purchase.
You can try Android free in DEBUG builds.
On Tue, Aug 22, 2017 at 1:51 PM Hamza L notifications@github.com wrote:
So I need now to install the latest using cordova plugin add cordova-background-geolocation-lt ? Even purchase the license to make it work ?
β You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub https://github.com/transistorsoft/cordova-background-geolocation-lt/issues/444#issuecomment-324102616, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA6l68VgU5QSPsq7vnJZpgzyQt6ALf8ks5saxU6gaJpZM4O-6nf .
-- Snet form Gmail Mobile
As you can see, responses to issues is quite rapid here.
You'll be lucky to get any response at all from Mauron85.
I see you re-posted your issue over at Mauron85.
You'll get no help there. You're on your own.
"You get what you pay for"
Well, I can't afford paying 300$ as I am currently a student and I'll be using the plugin for my capstone project
If it just for a project and you're not actually submitting to play-store, you can run the Android version in DEBUG builds.
iOS is free
I know, but I am required to submit it to the playStore and let people use it and also collect their feedback about it. Not sure, if there exists a special discount for students
I've installed the plugin in iOS after removing the mauron85 version and it didn't worked at all, here is the code :
this.platform.ready().then((ready) => {
this.configureBackgroundGeolocation(this);
});
this.configureBackgroundGeolocation() {
// 1. Get a reference to the plugin
this.bgGeo = (<any>window).BackgroundGeolocation;
// 2. Listen to events
this.bgGeo.on('location', this.onLocation.bind(this));
this.bgGeo.on('motionchange', this.onMotionChange.bind(this));
// 3. Configure it.
this.bgGeo.configure({
debug: false,
desiredAccuracy: 0,
distanceFilter: 10,
autoSync: true
}, (state) => {
// 4. Start the plugin.
this.bgGeo.start();
});
}
onLocation(location, taskId) {
console.log('- location: ', location);
this.bgGeo.finish(taskId);
}
onMotionChange(isMoving, location, taskId) {
console.log('- motionchange: ', isMoving, location);
this.bgGeo.finish(taskId);
}
When I go to the background even that blue bar does not show up, am I doing something wrong?
Logs.
When the app goes to the background I don't receive any logs, which means that possibly the plugin does not fire when being on the background
Why would you use debug: false
when something isn't working??
See logLevel
I'll change it now to debug: true
and let you know what happens
The blue bar isn't supposed to show.
changed it to debug: true
didn't changed anything
You'll get no logs without setting logLevel: bgGeo.LOG_LEVEL_VERBOSE
Where should I set it ?
Did you read the docs for logLevel
?
I've done the following:
this.bgGeo.configure({
debug: true,
desiredAccuracy: 0,
distanceFilter: 10,
logLevel: this.bgGeo.LOG_LEVEL_VERBOSE,
autoSync: true
}, (state) => {
// 4. Start the plugin.
this.bgGeo.start();
});`
Yes I did.
Even after adding logLevel: this.bgGeo.LOG_LEVEL_VERBOSE
I still don't get any logs
Then the plugin is not installed.
$ cordova plugins
cordova-background-geolocation-lt 2.8.2 "BackgroundGeolocation" cordova-plugin-actionsheet 2.3.3 "ActionSheet" cordova-plugin-background-fetch 5.0.0 "CDVBackgroundFetch" cordova-plugin-cocoalumberjack 0.0.4 "CocoaLumberjack" cordova-plugin-compat 1.1.0 "Compat" cordova-plugin-console 1.0.7 "Console" cordova-plugin-device 1.1.6 "Device" cordova-plugin-geolocation 2.4.3 "Geolocation" cordova-plugin-nativeaudio 3.0.9 "Cordova Native Audio" cordova-plugin-nativestorage 2.2.2 "NativeStorage" cordova-plugin-network-information 1.3.3 "Network Information" cordova-plugin-secure-storage 2.6.8 "SecureStorage" cordova-plugin-splashscreen 4.0.3 "Splashscreen" cordova-plugin-statusbar 2.2.3 "StatusBar" cordova-plugin-whitelist 1.3.2 "Whitelist" cordova.plugins.diagnostic 3.6.5 "Diagnostic" ionic-plugin-keyboard 2.2.1 "Keyboard" phonegap-plugin-push 2.0.0 "PushPlugin" uk.co.workingedge.phonegap.plugin.launchnavigator 3.2.2 "Launch Navigator"
As you can see, it's already installed...
Seems that this.configureBackgroundGeolocation(this);
never fires
That would be your problem.
Weird, I've placed the following this.configureBackgroundGeolocation(this);
in the exact place where mauron85 was. In the case of mauron85 it was firing without problem, but now cordova-background-geolocation-lt
does not fire up
I've done some changes to be like the following : this.platform.ready().then(this.configureBackgroundGeolocation.bind(this));
It seems that it fired.
Here is what I got :
CDVPlugin class CDVBackgroundGeolocation (pluginName: BackgroundGeolocation) does not exist. 2017-08-24 14:51:54.779030+0100 Onadi Driver[827:126850] ERROR: Plugin 'BackgroundGeolocation' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml. 2017-08-24 14:51:54.779194+0100 Onadi Driver[827:126850] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["BackgroundGeolocation760199973","BackgroundGeolocation","addLocationListener",[]] 2017-08-24 14:51:54.779325+0100 Onadi Driver[827:126850] CDVPlugin class CDVBackgroundGeolocation (pluginName: BackgroundGeolocation) does not exist. 2017-08-24 14:51:54.779366+0100 Onadi Driver[827:126850] ERROR: Plugin 'BackgroundGeolocation' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml. 2017-08-24 14:51:54.779421+0100 Onadi Driver[827:126850] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["BackgroundGeolocation760199974","BackgroundGeolocation","addMotionChangeListener",[]] 2017-08-24 14:51:54.779484+0100 Onadi Driver[827:126850] CDVPlugin class CDVBackgroundGeolocation (pluginName: BackgroundGeolocation) does not exist. 2017-08-24 14:51:54.779522+0100 Onadi Driver[827:126850] ERROR: Plugin 'BackgroundGeolocation' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml. 2017-08-24 14:51:54.779631+0100 Onadi Driver[827:126850] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["BackgroundGeolocation760199975","BackgroundGeolocation","configure",[{"logLevel":5,"autoSync":true,"debug":true,"desiredAccuracy":0,"distanceFilter":10}]]
The plugin is not installed properly. Cordova gets confused sometimes.
In your XCode project, you should see CDVBackgroundGeolocation
in the /Plugins
folder:
I didn't found CDVBackgroundGeolocation
in the /Plugins
folder
I'll re-install the plugin
It's Cordova's responsibility to place those files into the XCode project. Sometimes it fails. You probably uninstalled Mauron85 version after installing mine. The two plugins have identically named ios files CDVBackgroundGeolocation.m/.h
, since Mauron85 version is a fork of this project.
Now, it works fine only on foreground.
I get this :
βΉοΈ-[LocationDAO purge:] 1 π΅-[TSLocationManager setPace:] 0 β -[BackgroundTaskManager createBackgroundTask] 10 π΄-[TSLocationManager stopUpdatingLocation] 2017-08-24 15:09:50.875319+0100 Onadi Driver[871:132422] THREAD WARNING: ['BackgroundGeolocation'] took '58.497803' ms. Plugin should use a background thread. πΎ-[TSLocationManager requestLocation] Acquiring motionchange position 0 β -[BackgroundTaskManager stopBackgroundTask:]_block_invoke 9 OF ( 9, 10 ) πΎ-[TSLocationManager startMonitoringBackgroundFetch] BackgroundFetch: ON 2017-08-24 15:09:50.960471+0100 Onadi Driver[871:132422] - location: [object Object] 2017-08-24 15:09:50.962325+0100 Onadi Driver[871:132422] - location: [object Object] 2017-08-24 15:09:50.964551+0100 Onadi Driver[871:132422] - location: [object Object] 2017-08-24 15:09:50.964664+0100 Onadi Driver[871:132422] - location: [object Object] 2017-08-24 15:09:50.964754+0100 Onadi Driver[871:132422] started configureBackgroundGeolocationForIOS [object Object] β οΈ-[TSLocationManager start] Already started (ignored) 2017-08-24 15:09:51.082960+0100 Onadi Driver[871:132422] Upadte current driver location 1414 2017-08-24 15:09:51.083114+0100 Onadi Driver[871:132422] loca [object Object] 2017-08-24 15:09:51.083183+0100 Onadi Driver[871:132422] updateCurrentDriverLocation fired, drv st : true 2017-08-24 15:09:51.083413+0100 Onadi Driver[871:132422] this.driverStatus is true and this.driverOnWay is false 2017-08-24 15:09:51.083731+0100 Onadi Driver[871:132422] rm 2 0 2017-08-24 15:09:51.083932+0100 Onadi Driver[871:132422] update location now 2017-08-24 15:09:51.863261+0100 Onadi Driver[871:132422] **http observable π΅-[BackgroundTaskManager startPreventSuspendTimer:] BG time remaining: 179 | Total tasks: 1 π΅-[TSLocationManager onSuspend:] enabled? 1) π΅-[TSLocationManager setPace:] 0 β -[BackgroundTaskManager createBackgroundTask] 14 π΄-[TSLocationManager stopUpdatingLocation] πΎ-[TSLocationManager requestLocation] Acquiring motionchange position 0 β -[BackgroundTaskManager stopBackgroundTask:]_block_invoke 10 OF ( 10, 14 ) βΉοΈ-[TSDBLogger db_save] Log committed 2017-08-24 15:09:55.520870+0100 Onadi Driver[871:132422] - location: [object Object] 2017-08-24 15:09:55.521406+0100 Onadi Driver[871:132422] - location: [object Object] 2017-08-24 15:09:55.521756+0100 Onadi Driver[871:132422] - location: [object Object] 2017-08-24 15:09:55.522204+0100 Onadi Driver[871:132422] - location: [object Object] π΅-[BackgroundTaskManager startPreventSuspendTimer:] BG time remaining: 179 | Total tasks: 1 2017-08-24 15:09:58.935817+0100 Onadi Driver[871:132422] inside currentDriverLocation() 2017-08-24 15:09:58.936980+0100 Onadi Driver[871:132422] fired configureBackgroundGeolocationForIOS βΉοΈ-[TSLocationManager on:success:failure:] location βΉοΈ-[TSLocationManager on:success:failure:] motionchange
When going to the background, I get the following and stop updating the location
βΉοΈ-[LocationDAO purge:] 1
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β -[TSLocationManager stop] ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ π΄-[TSGeofenceManager stopMonitoringGeofences] π΄-[SOMotionDetector stopDetection] OFF π΄-[TSLocationManager stopUpdatingLocation] 2017-08-24 15:09:59.000041+0100 Onadi Driver[871:132422] [TSBackgroundFetch removeListener]: TSLocationManager 2017-08-24 15:09:59.008064+0100 Onadi Driver[871:132470] CoreLocation: Sending an un-cached message without first clearing the previously cached value 2017-08-24 15:09:59.012594+0100 Onadi Driver[871:132422] THREAD WARNING: ['BackgroundGeolocation'] took '72.111084' ms. Plugin should use a background thread. π΄-[TSLocationManager stopMonitoringBackgroundFetch] BackgroundFetch: OFF π΄-[TSLocationManager stopMonitoringSignificantLocationChanges] β -[BackgroundTaskManager stopBackgroundTask:]_block_invoke 14 OF ( 14 )
Background & Terminated are two completely different states. Are you terminating the app?
Not at all, only going to the background (for example opening Google maps, etc...)
Receiving the following :
π΄-[TSGeofenceManager stopMonitoringGeofences] π΄-[SOMotionDetector stopDetection] OFF π΄-[TSLocationManager stopUpdatingLocation] 2017-08-24 15:16:55.330214+0100 Onadi Driver[871:132422] THREAD WARNING: ['BackgroundGeolocation'] took '60.975586' ms. Plugin should use a background thread. π΄-[TSLocationManager stopMonitoringBackgroundFetch] BackgroundFetch: OFF π΄-[TSLocationManager stopMonitoringSignificantLocationChanges]
Also, I am getting a notification "Stopped on terminate"
Your app is being terminated, either by you or the OS. That's not the plugin's fault.
If you don't want tracking to cease when user or OS terminates your app, configure stopOnTerminate: false
I've solved it by accessing to the app settings and checked "Always" to enable background tracking even if the app is in the background. However, I am already setting a function that should trigger on an interval of 10 seconds but I receive a notification that says "Background fetch received" sometimes after 10 min or sometimes after 15min.. Any idea on what could be wrong?
You do not need to use cordova-plugin-geolocation
with this plugin. In fact, it's a bad idea, since cordova-plugin-geolocation
requests When In Use
permissions while this plugin requests Always
.
Whichever plugin requests location first, that's the authorization request which will be show to the user.
This plugin has its own #getCurrentPosition
method.
However, I am already setting a function that should trigger on an interval of 10 seconds
When an iOS app is in the background without locations-services on, your app is suspended. If you're hoping to do a setInterval
with Javascript while your app is in the background and the device is stationary, that's not going to happen.
a notification that says "Background fetch received" sometimes after 10 min or sometimes after 15min..
This plugin requires my cordova-plugin-background-fetch
plugin as a dependency. Read the docs for that plugin. This plugin is already included in your app and available to you at window.BackgroundFetch
. Feel free to implement a callback as documented there. The plugin uses this plugin internally for its own purposes.
Good then, I guess that I need to remove cordova-plugin-geolocation
but can I still get the current position when the user is on the foreground ?
However, for the cordova-plugin-background-fetch
It says that :
iOS Background Fetch is basically an API which wakes up your app about every 15 minutes
As of my understanding, it'll fetch each 15minutes, but I am willing to execute my function each 10 seconds. It's either my understanding is wrong or it's not possible to execute the function in background each 10 seconds when working with iOS
but can I still get the current position when the user is on the foreground ?
Yes, as I said above: "this plugin has its own getCurrentPosition method"
but I am willing to execute my function each 10 seconds. It's either my understanding is wrong
Your understanding is wrong. As I said above: "When an iOS app is in the background without locations-services on, your app is suspended. If you're hoping to do a setInterval with Javascript while your app is in the background and the device is stationary, that's not going to happen."
Read the plugin's Philosophy of Operation
Got it, basically. As of my understanding background fetch will happen only when the device is moving, getting a new user location and not in stationary. Please correct me if I am wrong.
Background fetch has nothing to do with geolocation or whether the device is moving.
Please read the docs.
I am using Ionic framework to develop my app, I've followed the documentation, everything works fine on Android; however on iOS it shows the blue bar that says that the app is tracking the current location on the background (only for the first 40 seconds), then that blue bar disappears and the app stop tracking the current location.
Your Environment
cordova -v
): 7.0.1cordova platform ls
): ios 4.4.0Expected Behavior
It should track the user current location in iOS even if the app goes to the background.
Actual Behavior
When going to the background, it shows the blue bar that says that the app is taking the current location on the background (only for the first 40 seconds), then that blue bar disappears and stop tracking the current location.
On the other hand, I have the same code working perfectly on Android devices, so I guess that there is an issue with the iOS.
Steps to Reproduce
Just follow the documentation on the following link : https://ionicframework.com/docs/native/background-geolocation/
Then run the app under iOS
Context
Track drivers location and update the database of the current driver location each 10 seconds.