Closed archee closed 8 years ago
I am experiencing the same situation.
Hey application uses cordova-plugin-geolocation for getting current position. Looks like somehow it cannot get position and I just found out that default timeout is inifite! which is insane. I set timeout explicity to 10sec.
OK I think I got it. The code seems to be OK, but there is total mess in plugins and permissions.
The repo was created with Cordova <v4, standard Ionic project has /plugins
in .gitignore
, thus clones people have on their computers don't have all (or uptodate) plugins.
My solution:
config.xml
cordova-plugin-geolocation
and cordova-plugin-whitelist
<allow-navigation href="*://*.openstreetmap.org/*" />
or just <allow-navigation href="*" />
to your config.xml
/platforms/android/AndroidManifest.xml
contains those lines <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
and <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
. I believe the installation of the geolocation plugin
will add those automatically but double check it.Voilà your starter would start ;)
HI @adyba , Tried all this. I didnt however remove plugins before reinstalling (Did you remove 1st?) I am using cordova 5.3.3. My issue is when adding a new location the map never loads?
It used to just hang on modal.Now modal goes but map never comes. ANy ideas?
Just a remote guess ... I have also had a problem to load leaflet
maps from openstreetmap.org
. Above some version of Cordova you have to allow remote IP adresses/data sources. Thus there is necessary to install cordova-plugin-whitelist
and inside config.xml
define what resources should be "open" (see my 4th bullet). href="*://*.openstreetmap.org/*
basicaly says consume everything from openstreetmap.org. I found this requirement in my Chrome console.
The <allow-navigation href="*" />
is just ONE BIG wildcard that condone everything (not very safe).
Good luck ;)
P.S. The geofence plugin was present. To be honest I don't remember whether I reainstalled it or not. The current versions of plugins use to have a 'slash notation' like plugin-name
instead of plugin.name
We don't need any allow-navigation
if I have good understanding of cordova-plugin-whitelist
documentation. We need <access origin="*.openstreetmap.org"/>
for webviews which don't support CSP and also I've added CSP meta tag.
You maid be right but the access origin
would potentially need a propper Cordova hook setting which is actually what I'm trying to avoid in order to get our clones as close as it gets to the environmet on your desktop. As the navigation
is subset of access
and it is already present and set up in a Ionic app I believe Its OK to use it while it is not totally wild wildcard.
Closing due to inactivity.
Testing on both a Samsung Galaxy S6 running Lollipop 5.0.2 and an Android emulator running KitKat 4.4.2. When clicking on the + icon to add a new geofence, the screen gets stuck on the "Obtaining current location..." popup modal and nothing happens. Upon further inspection of the logs, it appears there is a permissions issue with using the Android device's location service, as indicated by this log entry:
07-08 19:20:15.731 1282-1282/com.tsubik.ionicgeofence E/LocationProvider﹕ Caught security exception registering for location updates from system. This should only happen in DumpRenderTree.