最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Cordova Geolocation Issues in iOS 8 Beta 2 - Stack Overflow

programmeradmin4浏览0评论

This is more of an informational post: I've spent the past few days struggling with a non-functional geolocation app on the latest iOS 8 Beta.

At first I wasn't sure if it was isolated to iOS 8, or if it was an issue of device vs simulator, but after re-downloaded XCode 6 Beta 2 (my first download had a broken simulator for some reason), I confirmed that indeed, iOS 8 Beta 2 simulator did not seem to like my attempts at grabbing a geolocation.

At first the call didn't seem to work at all; then I made a change from including phonegap.js to including cordova.js and finally made some progress. The documentation is awful on this, as following guides in the official docs seems to lead one to believe they're interchangeable. I would suggest those with issues check that first.

Rather than running the navigator.geolocation.getCurrentPosition(....) callback functions as expected, it would instead hang and not do anything at all. Sometimes navigating away from the page and back to it would force the error callback, but it was very inconsistent. After setting a { timeout: 5000 } option, it seemed to keep timing out every call. There were no errors to the console, no errors in XCode, nothing. The success function just would not run, period, and neither would the error callback if I didn't explicitly timeout after X seconds. This is an error isolated to the iOS 8 Beta, so nothing of concern to most (yet), but I felt I should post this in case someone ran into it. I'll also be posting on the Apple Dev Center.

This is more of an informational post: I've spent the past few days struggling with a non-functional geolocation app on the latest iOS 8 Beta.

At first I wasn't sure if it was isolated to iOS 8, or if it was an issue of device vs simulator, but after re-downloaded XCode 6 Beta 2 (my first download had a broken simulator for some reason), I confirmed that indeed, iOS 8 Beta 2 simulator did not seem to like my attempts at grabbing a geolocation.

At first the call didn't seem to work at all; then I made a change from including phonegap.js to including cordova.js and finally made some progress. The documentation is awful on this, as following guides in the official docs seems to lead one to believe they're interchangeable. I would suggest those with issues check that first.

Rather than running the navigator.geolocation.getCurrentPosition(....) callback functions as expected, it would instead hang and not do anything at all. Sometimes navigating away from the page and back to it would force the error callback, but it was very inconsistent. After setting a { timeout: 5000 } option, it seemed to keep timing out every call. There were no errors to the console, no errors in XCode, nothing. The success function just would not run, period, and neither would the error callback if I didn't explicitly timeout after X seconds. This is an error isolated to the iOS 8 Beta, so nothing of concern to most (yet), but I felt I should post this in case someone ran into it. I'll also be posting on the Apple Dev Center.

Share Improve this question asked Jun 24, 2014 at 17:36 Ruben Martinez Jr.Ruben Martinez Jr. 3,1105 gold badges45 silver badges77 bronze badges 1
  • I'm running into the same problem. My error function is set to retrieve the location via IP address, so using a timeout still sorta works. Would like this fixed, however. You should file a bug report. – Charlie Commented Aug 8, 2014 at 18:26
Add a ment  | 

1 Answer 1

Reset to default 16

It's a known issue and is fixed here:

https://github./apache/cordova-plugin-geolocation/mit/4102a332b0c6b0c3513370a4c030a32e46a51e10#mitment-7791523

Just tested it in iOS8, it works.

Run the following mand in platforms/ios folder of your phonegap project:

cordova plugin rm org.apache.cordova.geolocation
cordova plugin add https://github./apache/cordova-plugin-geolocation.git   

For some reason it removes the CDVLocation.m from the pilation list, you need to revert that.

The entries In XXX.xcodeproj/project.pbxproj:

979B00CA27D6412CB8C6CF74 /* CDVLocation.m in Sources / = {isa = PBXBuildFile; fileRef = E3B4F7C4AF8242A09E9BF8C1 / CDVLocation.m */; };
979B00CA27D6412CB8C6CF74 /* CDVLocation.m in Sources */,

Without these 2 lines, the plugin is not available to use in the app.

If you have that file in source control just revert the deletions related to CDVLocation.m in XXX.xcodeproj/project.pbxproj.

If not try add CDVLocation.m to the Compile Sources step in the Build Phases in the project settings.

发布评论

评论列表(0)

  1. 暂无评论