cowbell / ionic-geofence

Ionic geofence app example
MIT License
180 stars 92 forks source link

Cannot use location services on Android devices #11

Closed archee closed 8 years ago

archee commented 9 years ago

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.

dylboy commented 9 years ago

I am experiencing the same situation.

tsubik commented 9 years ago

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.

adyba commented 9 years ago

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:

Voilà your starter would start ;)

dylboy commented 9 years ago

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?

adyba commented 9 years ago

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

tsubik commented 9 years ago

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.

adyba commented 9 years ago

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.

tsubik commented 8 years ago

Closing due to inactivity.