Since I basically can get the same info with both approaches, I'm wondering which is the preferred one and what are the advantages using one over the other?
相关问题
- Plugin with id 'com.google.gms.google-services
- How to pass form data from Ionic 3 to PHP file?
- apk big size with ionic 4 build
- Ionic Spinner not showing up
- Is there any way to make the background of a 3D-mo
相关文章
- Ionic 4: Hardware Back Button Reloading Applicatio
- ionic - Copy/paste in input field in iOS 10 not wo
- net::ERR_CONNECTION_REFUSED ionic
- Typescript Error: Property 'files' does no
- ionic 4 + angular: routerLink only works first tim
- Ionic conditional class css
- Ionic tabs and side menu navigation issue
- After reseting plugins, Ionic 2 program doesn'
$cordovaGeolocation
is angular wrapper over plain javascript plugin, developed byionic
. Now question is why ngCordova was introduced,in simple words to deal it as plugin service as module and inject plugin wrapper as dependency to only particular controller or service.On Pratical level, cordova developers were having issues with plugins on angular project. One simple issue was that
$scope
does not get updated sometimes in simple plugins callback.Quoting from ionic blog post :
So my conclusion is, you should go with
$cordovaGeolocation
.As far as I remember, on Android that plugin does not do anything at all, and on iOS it prevents the OS asking for access to location over and over.
Overall the plugin totally conforms the html5 specs, so you shouldn't change anything in your calling code (in js) if you use the plugin.
And the plugin has a good documentation here: https://github.com/apache/cordova-plugin-geolocation/blob/master/doc/index.md
It is worth noting that according to the current and oficial documentation (see cordova geolocation doc), there is no need to use $cordovaGeolocation, but rather the global object navigator.geolocation.