louisbl / cordova-plugin-locationservices Goto Github PK
View Code? Open in Web Editor NEWGoogle Location Services for Cordova/Android
License: Apache License 2.0
Google Location Services for Cordova/Android
License: Apache License 2.0
Hi!
Thanks for your great plugin!
I am starting/stoping LocationServices via an ActivityRecognition service and sometimes (cannot reproduce it), I am getting this TypeError "LocationServices.lastPosition.timestamp.getTime is not a function" and LocationServices fail to start.
Plugin version: 1.2.0
Options: {
enableHighAccuracy: true,
timeout : 12000,
maximumAge : 60000,
priority: LocationServices.priorities.PRIORITY_BALANCED_POWER_ACCURACY,
interval: 10000,
fastInterval: 5000
}
Device: Samsung Duos Android 4.2
Could you please advise?
Thank you!
Regards,
Stelios
Trying to access cordova.plugins.locationServices.geolocation.priorities.PRIORITY_HIGH_ACCURACY
gets Uncaught TypeError: Cannot read property 'PRIORITY_HIGH_ACCURACY' of undefined
When I do below commands:
I get error "Error during processing of action .. "
What I do wrong? Early this case worked good.
Can someone confirm if this works with ionic2 ?
The class is not even detected after installing the plugin. Could someone provide an ionic2 example?
Thanks
Google recently (June 17, 2019) released version 17.0.0 of the location services library. This release includes the following breaking change:
Migration from Android Support Libraries to Jetpack (AndroidX) Libraries.
See the Google Play Services Release Notes for more information.
This change results in a build failure with the following error if the Android Support library is used by another plugin (for example cordova-plugin-camera):
Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver
As a short term work-around is to use version 16.0.0 of the location services library. This can be achieved by changing the following line in the plugin.xml file from:
<framework src="com.google.android.gms:play-services-location:+" />
to
<framework src="com.google.android.gms:play-services-location:16.+" />
This will allow the app to build again.
Trying to install this plugin in sample project but got the following error while installing the plugin
cordova plugin add fr.louisbl.cordova.locationservices Fetching plugin "fr.louisbl.cordova.locationservices" via plugin registry Installing "fr.louisbl.cordova.locationservices" for android Error during processing of action! Attempting to revert... Failed to install 'fr.louisbl.cordova.locationservices':Error: Uh oh! ENOENT, no such file or directory '/dinesh/WorkSpace/OfficeWork/BizFlirt/testForLocation/hello/platforms/android/local.properties' at Object.fs.openSync (fs.js:439:18) at Object.fs.readFileSync (fs.js:290:15) at Object.createEditor (/usr/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/properties-parser/index.js:328:39) at Object.module.exports.getProjectSdkDir (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/android.js:172:49) at module.exports.framework.install (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/android.js:120:46) at Object.ActionStack.process (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/action-stack.js:72:25) at handleInstall (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:591:20) at /usr/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:340:28 at _fulfilled (/usr/lib/node_modules/cordova/node_modules/q/q.js:787:54) at self.promiseDispatch.done (/usr/lib/node_modules/cordova/node_modules/q/q.js:816:30) Error: Uh oh! ENOENT, no such file or directory '/dinesh/WorkSpace/OfficeWork/BizFlirt/testForLocation/hello/platforms/android/local.properties' at Object.fs.openSync (fs.js:439:18) at Object.fs.readFileSync (fs.js:290:15) at Object.createEditor (/usr/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/properties-parser/index.js:328:39) at Object.module.exports.getProjectSdkDir (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/android.js:172:49) at module.exports.framework.install (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/android.js:120:46) at Object.ActionStack.process (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/action-stack.js:72:25) at handleInstall (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:591:20) at /usr/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:340:28 at _fulfilled (/usr/lib/node_modules/cordova/node_modules/q/q.js:787:54) at self.promiseDispatch.done (/usr/lib/node_modules/cordova/node_modules/q/q.js:816:30)
On Samsung Galaxy S7 Edge, Android 7.0,
My app crashes right after showing Permission dialog, and throws :
Client must have ACCESS_FINE_LOCATION permission to request PRIORITY_HIGH_ACCURACY locations.
If I choose "Yes" and re-run my app, Location works perfectly.
It's not very professional to have an app crashing at first launch.
Thank you for your answer
Hey guys. Any plan to extend plugin with Android 6 permission model? I believe updated version of cordova-plugin-geolocation
can be used as an example.
How to replicate
OS: Android 6.0
Error from log:
Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.SecurityException: Client must have ACCESS_FINE_LOCATION permission to request PRIORITY_HIGH_ACCURACY locations.
at android.os.Parcel.readException(Parcel.java:2004)
at android.os.Parcel.readException(Parcel.java:1950)
at com.google.android.gms.internal.zzed.zzb(Unknown Source:10)
at com.google.android.gms.internal.zzcda.zza(Unknown Source:9)
at com.google.android.gms.internal.zzcdd.zza(Unknown Source:40)
at com.google.android.gms.internal.zzcdj.zza(Unknown Source:5)
at com.google.android.gms.internal.zzccc.zza(Unknown Source:25)
at com.google.android.gms.internal.zzbay.zzb(Unknown Source:0)
at com.google.android.gms.internal.zzbca.zze(Unknown Source:68)
at com.google.android.gms.internal.zzbcx.zze(Unknown Source:5)
at com.google.android.gms.internal.zzbcp.zze(Unknown Source:147)
at com.google.android.gms.internal.zzccb.requestLocationUpdates(Unknown Source:14)
at fr.louisbl.cordova.locationservices.CordovaLocationListener.start(CordovaLocationListener.java:167)
at fr.louisbl.cordova.locationservices.CordovaLocationServices.onConnected(CordovaLocationServices.java:117)
at com.google.android.gms.common.internal.zzac.zzn(Unknown Source:108)
at com.google.android.gms.internal.zzbcp.zzm(Unknown Source:22)
at com.google.android.gms.internal.zzbcd.zzpY(Unknown Source:89)
at com.google.android.gms.internal.zzbcd.onConnected(Unknown Source:21)
at com.google.android.gms.internal.zzbcx.onConnected(Unknown Source:7)
at com.google.android.gms.internal.zzbbi.onConnected(Unknown Source:5)
at com.google.android.gms.common.internal.zzaa.onConnected(Unknown Source:2)
at com.google.android.gms.common.internal.zzn.zzrj(Unknown Source:147)
at com.google.android.gms.common.internal.zze.zzs(Unknown Source:47)
at com.google.android.gms.common.internal.zzi.zzrk(Unknown Source:54)
at com.google.android.gms.common.internal.zzh.handleMessage(Unknown Source:275)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
(Translated by Google)
I received an email from " Google Play" (it is copied below ) , indicating a change to the permissions of GPS
Does this plugin will update to resolve this issue?
Or that change should do in our apps?
Thank you
Hello Google Play Developer,
We're writing to let you know that the apps listed at the end of this email may be affected by an upcoming platform change.
Action required: If your app requires GPS hardware to operate properly, you will need to explicitly add the "android.hardware.location.gps" uses-feature to your manifest.
What’s changing
We’re making a change on October 15th, 2016 that will affect apps targeting API version 21 (Android 5.0, Lollipop) or higher that use ACCESS_FINE_LOCATION but don't explicitly have the "android.hardware.location.gps" uses-feature. Going forward, these apps will be available to install on devices that don't have GPS hardware. In most cases this won't be an issue since Wi-Fi and Cell-ID based location provides high enough fidelity for the typical operation of these apps. However, any apps that require GPS hardware, such as GPS navigators, should explicitly add the "android.hardware.location.gps" uses-feature to their manifest.
If your app requires GPS to function properly and you do not include android.hardware.location.gps in your manifest declaration, your users may have a poor app experience.
Also, if you’re using the fused location provider and wish to receive the most accurate location samples from GPS (i.e. with PRIORITY_HIGH_ACCURACY), you must include the "android.hardware.location.gps" feature in your app’s manifest to ensure that Google Play only distributes your app to devices with GPS sensors.
You can read more about this change in the Android Developers Help Center.
Regards,
The Google Play Team
Can't find anything about this notification in sources.
Hello, is there a way to detect when the user turn off the location settings when we are watching his position?
In the default locationservices it's trigger the error callback if he turn off the location. With the google play service it's just stop triggering the success callback.
I don't know if I am clear ^^
Hello! First of all, thx for the great work on this plugin.
On the Android side of things, because there is a new player in town when it comes to mobile services (Huawei) it would be great if Huawei Mobile Services fused location provider would be supported by your plugin as well.
There is a quick way to accomplish this - the integration effort would not go beyond 15 minutes of your time.
On native apps, developers are already using my wrapper library: https://github.com/abusuioc/hms-gms-wrapper-location
The library allows you to immediately have location services available on HMS devices if you already own a Google Play Services (GMS) location implementation, as you do. The main advantage is that you can leave the code structure unchanged because the wrapper API follows the GMS API 1:1 and what it does under the hood is simply to route the calls depending on availability: the default preference is still GMS.
Let's discuss more if you have further questions.
I hope this helps you and it will help other users of your library.
I know that it used to work, because I've been using it for a couple of months.
But today, impossible to make it work, and I have no idea why.
For getPosition for instance, I can debug until
exec(win, errorCallback, 'LocationServices', 'getPermission', []);
And then... nothing.
win is never called, nor errorCallback
I even tried to come back to a previous version, and still nothing.
I totally don't understand, and I don't know what to do.
Is there something special I need to have in my config.xml, or something like that ?
I called watchPosition function, I am getting the locations 2 or 3 minutes once.
Sometime, It is taking 3 to 4 minutes to get the location updates, But it returns bulk(10 to 20 entries) locations at once.
It seems, It collects the location every 1 minute and It is not returning every one minute, It is returned every 2 or 3 min randomly with all the collected location detail. Sometimes It gives location details after 4 or 5 minutes.
Options:
{maximumAge : 0, timeout: 15000, enableHighAccuracy: true,
priority: cordova.plugins.locationServices.geolocation.priorities.PRIORITY_HIGH_ACCURACY, interval: 1000, fastInterval: 5000}
Hello,
When I use the plugin, even with the options that active enableHightAccucary:false
and priority: cordova.plugins.locationServices.geolocation.priorities:PRIORITY_NO_POWER
the plugin still active gps, while information over the network enough for me in most cases. Besides the plugin sends me the value of the location via the network before the position via the GPS is available. Did I miss an option to force disable GPS ?
I use version 1.2.0 of the plugin with version 4.1.1 of cordova.
Thanks.
I'd like to work with speed value of GPS instead of calculating it myself, but I'm wondering, which unit of measerent the speed value of plugin actually has? I was driving 15 kilometers per hour and the value was like 1.2 (?)
I am using cordova 6.0.0 and a default cordova project with just a call to cordova.plugins.locationServices.geolocation.watchPosition(positionSuccess, positionFailed, geolocationOptions);
The problem is that the API method watchPosition is returning undefined
because the watchID is only generated asynchronously at the next tick. The solution here is just to generate the watchID in the synchronous API method and pass it forward to LocationServicesWithoutPermission.watchPosition
.
I already fixed it for the project I work on but I will submit a new PR for this issue.
Cheers
It shows security exception on some android models
Example : Gionee S6s (GIONEE_WBL7519), 3072MB RAM, Android 7.0
Stacktrace of exception
java.lang.SecurityException:
at android.os.Parcel.readException (Parcel.java:1683)
at android.os.Parcel.readException (Parcel.java:1636)
at com.google.android.gms.internal.zzeu.zzb (Unknown Source)
at com.google.android.gms.internal.zzcfa.zza (Unknown Source)
at com.google.android.gms.internal.zzcfd.zza (Unknown Source)
at com.google.android.gms.internal.zzcfk.zza (Unknown Source)
at com.google.android.gms.internal.zzcec.zza (Unknown Source)
at com.google.android.gms.common.api.internal.zzm.zzb (Unknown Source)
at com.google.android.gms.common.api.internal.zzal.zze (Unknown Source)
at com.google.android.gms.common.api.internal.zzbi.zze (Unknown Source)
at com.google.android.gms.common.api.internal.zzba.zze (Unknown Source)
at com.google.android.gms.internal.zzceb.requestLocationUpdates (Unknown Source)
at fr.louisbl.cordova.locationservices.CordovaLocationListener.start (CordovaLocationListener.java:167)
at fr.louisbl.cordova.locationservices.CordovaLocationListener.addCallback (CordovaLocationListener.java:110)
at fr.louisbl.cordova.locationservices.CordovaLocationServices.getCurrentLocation (CordovaLocationServices.java:331)
at fr.louisbl.cordova.locationservices.CordovaLocationServices.getLastLocation (CordovaLocationServices.java:315)
at fr.louisbl.cordova.locationservices.CordovaLocationServices.getLastLocation (CordovaLocationServices.java:292)
at fr.louisbl.cordova.locationservices.CordovaLocationServices.onConnected (CordovaLocationServices.java:113)
at com.google.android.gms.common.internal.zzae.zzk (Unknown Source)
at com.google.android.gms.common.api.internal.zzba.zzj (Unknown Source)
at com.google.android.gms.common.api.internal.zzao.zzaie (Unknown Source)
at com.google.android.gms.common.api.internal.zzao.onConnected (Unknown Source)
at com.google.android.gms.common.api.internal.zzbi.onConnected (Unknown Source)
at com.google.android.gms.common.api.internal.zzt.onConnected (Unknown Source)
at com.google.android.gms.common.internal.zzac.onConnected (Unknown Source)
at com.google.android.gms.common.internal.zzn.zzakr (Unknown Source)
at com.google.android.gms.common.internal.zze.zzw (Unknown Source)
at com.google.android.gms.common.internal.zzi.zzaks (Unknown Source)
at com.google.android.gms.common.internal.zzh.handleMessage (Unknown Source)
at android.os.Handler.dispatchMessage (Handler.java:110)
at android.os.Looper.loop (Looper.java:203)
at android.app.ActivityThread.main (ActivityThread.java:6269)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:924)
With message
ReferenceError: errorCallback is not defined at Object.LocationServices.watchPosition (LocationServices.js:251)
I think that, in LocationServices.js,
line 245
watchPosition: function(success, error, args) {
should be replaced by
watchPosition: function(successCallback, errorCallback, args) {
and same for clearWatch line 253
According to the spec (http://www.w3.org/TR/geolocation-API/#position_interface) the timestamp field of the Position object should have the Number, not Date data type.
Hi again. Some time ago I've noticed one drawback of using Fused Location API - if you press on the home button, GPS icon is displaying still. This is unlike HTML5 implementation that stop GPS tracking immediately if window is not visible anymore.
You can do a fix in JavaScript:
document.addEventListener("visibilitychange", function() {
if (document.hidden) {
// stop watching
} else {
// start watching again
}
}, false);
Or you can handle the issue on Java side. Either way, it should be a default behavior - battery charging can be significant on mobile devices.
On the other hand working in background is a nice feature, I'd vote to have an extra background
option for the watch
method config, which is false
by default.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.