I created an Ionic project to convert an existing AngularJS webapp to a hybrid app. Works perfectly.
I added cordova-plugin-geolocation to get the geolocation working, which did, but I saw that the corodova.plugins.diagnostic has better support, so I added that. However, to get that working I had to add to index.html <script src="cordova.js"></script> which wasn't in before.
So, I now try to get the location authorization when the app loads as follows:
When looking in the console I do see Diagnostic plugin ready, but nothing happens. When I run in the chrome console window.cordova.plugins.diagnostic.getLocationAuthorizationStatus(function(status) {console.log('status: ' + status)}, function(error) {console.log (error)}); I get undefined.
When I try the classical window.navigator.geolocation.getCurrentPosition(onSuccess, onError, options) I also get undefined.
When I remove <script src="cordova.js"></script> I don't have access to window.cordova, but now the callback of window.navigator.geolocation.getCurrentPositionworks again.
So, in short: adding <script src="cordova.js"></script> prevents these callbacks.
I already removed and added again the Android platform, but all stays the same. Can anyone help?
I created an Ionic project to convert an existing AngularJS webapp to a hybrid app. Works perfectly.
I added
cordova-plugin-geolocation
to get the geolocation working, which did, but I saw that thecorodova.plugins.diagnostic
has better support, so I added that. However, to get that working I had to add to index.html<script src="cordova.js"></script>
which wasn't in before.So, I now try to get the location authorization when the app loads as follows:
When looking in the console I do see
Diagnostic plugin ready
, but nothing happens. When I run in the chrome consolewindow.cordova.plugins.diagnostic.getLocationAuthorizationStatus(function(status) {console.log('status: ' + status)}, function(error) {console.log (error)});
I getundefined
.When I try the classical
window.navigator.geolocation.getCurrentPosition(onSuccess, onError, options)
I also getundefined
.When I remove
<script src="cordova.js"></script>
I don't have access towindow.cordova
, but now the callback ofwindow.navigator.geolocation.getCurrentPosition
works again.So, in short: adding
<script src="cordova.js"></script>
prevents these callbacks.I already removed and added again the Android platform, but all stays the same. Can anyone help?
Thank you!
Chris
my package.json file