Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use location services on Android devices #11

Closed
archee opened this issue Jul 8, 2015 · 8 comments
Closed

Cannot use location services on Android devices #11

archee opened this issue Jul 8, 2015 · 8 comments

Comments

@archee
Copy link

archee commented Jul 8, 2015

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
Copy link

dylboy commented Oct 26, 2015

I am experiencing the same situation.

@tsubik
Copy link
Member

tsubik commented Oct 26, 2015

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
Copy link

adyba commented Oct 27, 2015

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:

  • Update the Cordova
  • Manually reinstall all the cordova plugins mentioned in config.xml
  • Make sure you have installed cordova-plugin-geolocation and cordova-plugin-whitelist
  • Add <allow-navigation href="*://*.openstreetmap.org/*" /> or just <allow-navigation href="*" /> to your config.xml
  • Make sure your /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 ;)

@dylboy
Copy link

dylboy commented Oct 27, 2015

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
Copy link

adyba commented Oct 27, 2015

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
Copy link
Member

tsubik commented Oct 27, 2015

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
Copy link

adyba commented Nov 5, 2015

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
Copy link
Member

tsubik commented Jan 22, 2016

Closing due to inactivity.

@tsubik tsubik closed this as completed Jan 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants