Recently while working on an app for a client i came across a very strange bug, Our code for a phonegap based app using geolocation was working for everything other then iOS 8, As per usual i quickly had a look around on stack overflow and the official cordova forums and it seemed it wasn’t just me having the problem! So below is a step by step guide to getting geolocation back working on your phonegap / cordova application for iOS 8!
Remove and install the geolocation plugin
First step is to make sure your geolocation plugin is upto date (at the time of writing geolocation is at version 0.3.11)
You can do this with the two commands below:
cordova plugin rm org.apache.cordova.core.geolocation
This command removes the plugin
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
This one installs the plugin again
Making sure your config.xml is upto scratch
Next you need to make sure your config.xml file in the root of your project is correct, it should have this following line for the geolocation plugin:
Fixing the bug in Xcode
Finally you need to make a tweak in xcode for this all to work
In the main screen you will see the ‘Build Phases’ tab at the top, click this
Under ‘Compile Sources’ you will now need to press the + button and add ‘CDVLocation.m‘
You are now done! All you need to do is recompile & build the .ipa, deploy to your device and test it is now all working, If you still experience problems its worth uninstalling the app and reinstalling from fresh (rather then update an app), Also! remember to make sure your location services are turned on in the settings!