Closed vedantterkar closed 6 years ago
Listen to providerchange event.
@christocracy , Is there any way to open location settings page?
Any API equivalent to: BackgroundGeolocation.showLocationSettings();
?
No, but I believe there are 3rd-party plugins that can do this.
providerChange event listener is not working in my case..
I've written it like:
backgroundGeolocation.on("location", this.setLocation.bind(this), this.handleError.bind(this) );
/**RESPONSE FROM christocracy TO DETECT GPS CHANGES */
backgroundGeolocation.on('providerchange', function(provider) {
debugger
console.log('- Provider Change: ', provider);
console.log(' enabled: ', provider.enabled);
console.log(' gps: ', provider.gps);
console.log(' network: ', provider.network);
console.log(' status: ', provider.status);
if(provider.status != 3)
{
alert("LOcation settings changed");
}
});
backgroundGeolocation.configure(this.config, this.setLocation.bind(this), this.handleError.bind(this) );
Still when I turn off GPS or If I turn it on again.. Nothing is getting printed in logs and no Alert is coming.
Also There is one more issue, .configure()
method always calls failureCallbackFn
insted of calling SuucessCallbackFn
Can you please help in this?
You're not attempting to boot this in the browser, are you?
What is the error returned from failureCallbackFn
?
#configure
failing is the issue. If #configure
fails, nothing will work.
It says invalid action.
On May 23, 2017 8:33 PM, "Chris Scott" notifications@github.com wrote:
What is the error returned from failureCallbackFn?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/transistorsoft/cordova-background-geolocation-lt/issues/350#issuecomment-303427070, or mute the thread https://github.com/notifications/unsubscribe-auth/AYzDUsLtOeDY9muFePcIrgcCbJ25oys2ks5r8vUigaJpZM4NjTv4 .
Show me your $ cordova plugins
Though configure
is falling, call to start
is working fine and it is
fetching correctly fetching locations.
Show me your $ cordova plugins
and I'll tell you exactly what's going on.
@christocracy, Here is output of cordova plugins command:
$cordova plugins cordova-background-geolocation-lt 2.7.1 "BackgroundGeolocation" cordova-custom-config 3.1.2 "cordova-custom-config" cordova-plugin-app-version 0.1.9 "AppVersion" cordova-plugin-background-fetch 4.0.2 "CDVBackgroundFetch" cordova-plugin-camera 2.2.0 "Camera" cordova-plugin-compat 1.1.0 "Compat" cordova-plugin-console 1.0.6 "Console" cordova-plugin-device 1.1.5 "Device" cordova-plugin-dialogs 1.3.3 "Notification" cordova-plugin-mauron85-background-geolocation 2.2.5 "CDVBackgroundGeolocation" cordova-plugin-network-information 1.3.1 "Network Information" cordova-plugin-splashscreen 4.0.2 "Splashscreen" cordova-plugin-sqlite-2 1.0.4 "SQLitePlugin" cordova-plugin-statusbar 2.2.2 "StatusBar" cordova-plugin-whitelist 1.3.2 "Whitelist" cordova.plugins.diagnostic 3.3.3 "Diagnostic" ionic-plugin-deeplinks 1.0.14 "Ionic Deeplink Plugin" ionic-plugin-keyboard 2.2.1 "Keyboard"
@christocracy
Also Is there any way to get location after every "n" minutes on IOS?
I know there is locationUpdateInterval
But I think it is Android specific. Any Idea for IOS?
You problem is this:
cordova-plugin-mauron85-background-geolocation 2.2.5 "CDVBackgroundGeolocation"
You need to remove that. You can't use both Mauron85's old fork in addition to this plugin.
This plugin has a different API and config params. You need to start from scratch implementing my plugin. Your Javascript code for Mauron85's version is incompatible with mine.
Also Is there any way to get location after every "n" minutes on IOS? I know there is locationUpdateInterval But I think it is Android specific. Any Idea for IOS?
My plugin includes my iOS background-fetch plugin as a dependency:
cordova-plugin-background-fetch 4.0.2 "CDVBackgroundFetch"
This plugin will fire its fetch event typically every 15min, even while the device is stationary.
Can I make it customizable, Say If I want location after every 2 mins (ios)? Can I do it?
Thanks for your help :).
iOS background-fetch API's minimum interval is 15 min.
Hi, I uninstalled another plugin and tested this one. It works fine.
Now Just one question; Every time I call configure
it asks the user for location sharing permission; though my app has been given location sharing permission as "Always"?
I don't want to show location sharing permission dialog box if permission is already given.
Any idea How can we do it?
Really Appreciate your help.
The plugin does not ask for location permission if already granted.
The question for you is: "why is the location permission being revoked causing the plugin to have to re-ask for permission?"
@christocracy ,
I was uninstalling and re-installing app for testing purpose and thats why it was asking for location permissions again and again.
Now That issue is resolved.
As I mentioned earlier
@christocracy Also Is there any way to get location after every "n" minutes on IOS? I know there is locationUpdateInterval But I think it is Android specific. Any Idea for IOS?
As Location update interval is 15mins on IOS; I tried to use .on("heartbeat")
API with heartbeatInterval: 60
(60 secs).
It works fine in both IOS and Android in foreground and background mode; But There is one issue which I noticed recently; After some time Let us say 10mins; instead of firing heartbeat
event after specified interval (60sec) It was firing it after much larger time of 5minutes.
Is it because of my config settings?
this.config = {
desiredAccuracy: 10,
stationaryRadius: 0,
distanceFilter: 0,
debug: true,
stopOnTerminate: false,
startForeground: true,
locationProvider: 1,
locationUpdateInterval: 60 * 1000
fastestInterval: (60 * 1000) / 2,
activitiesInterval: (60 * 1000) / 2,
stopOnStillActivity: false,
pauseLocationUpdates: false,
activityType: 'AutomotiveNavigation',
notificationText: this.notificationText,
notificationTitle: this.notificationTitle,
useSignificantChangesOnly: false,
locationAuthorizationRequest: 'Always',
activityRecognitionInterval: 100,
heartbeatInterval: 60,
preventSuspend: true,
trackingMode: 'location'
};
Or is it something else? Thanks in advance.
and as mentioned in documentation;
.on("location")
will be fired as soon as new location is detected, That means on IOS it'll be fired too right? or will it be fired after 15mins only even if .on('location')
is changed?
And what is the minimum distance needs to be travelled to trigger .on('location')
You are getting way off topic from the original subject "How Can I Know If GPS is Enabled and If not How Can I open settings from APP".
This issue is closed. I will talk no further on this thread.
@christocracy, Thanks. I'll create new thread for this.
@christocracy
Created a new Thread: https://github.com/transistorsoft/cordova-background-geolocation-lt/issues/354
I want to know if GPS is enabled and app is able to access the GPS, If any of this is not true, Then I'll like to open settings. Is this possible?
Environment
Plugin version: 2.7.0
Platform: Android
OS version: 6
Cordova version (
cordova -v
): 6.5.0Plugin config
Expected Behavior
I want to check GPS/location settings before start (if location is not enabled, We can show some alert or open settings)
Actual Behavior
It just asks that APP requires Permission to access Location.
Context
I want to check GPS/location settings before start (if location is not enabled, I want to open settings) Is it possible?