简体   繁体   English

在iOS 6上,getCurrentPosition几乎总是在PhoneGap 1.3中失败

[英]getCurrentPosition almost always failing in PhoneGap 1.3 on iOS 6

I have an existing PhoneGap 1.3 app that does some geolocation that works just fine in iOS 4 and 5. In iOS 6, getCurrentPosition almost always fires the failure callback. 我有一个现有的PhoneGap 1.3应用程序可以做一些在iOS 4和5中运行良好的地理位置。在iOS 6中,getCurrentPosition几乎总是触发故障回调。 After a failure, additional getCurrentPosition calls do not fire either the success or failure callbacks. 发生故障后,其他getCurrentPosition调用不会触发成功或失败回调。 I've reduced the app down to the following code, which exhibits the same behavior as my full app. 我已将应用程序缩减为以下代码,该代码与我的完整应用程序具有相同的行为。

document.addEventListener("deviceready", function() {
  console.log('deviceready!!!');
  successCallback = function() {
    console.log('success!!!');
  };
  failureCallback = function() {
    console.log('failure!!!');
    navigator.geolocation.getCurrentPosition(function() { console.log('success 2'); }, function() { console.log('failure 2'); });
  };
  navigator.geolocation.getCurrentPosition(successCallback, failureCallback);
}, false);

When it fails, this is what I get in the log: 当它失败时,这就是我在日志中得到的:

2012-09-24 16:26:46.576 MyAppName[7250:16703] [INFO] deviceready!!!
2012-09-24 16:26:56.582 MyAppName[7250:16703] [INFO] failure!!!

Nothing more. 而已。

Any ideas on where to go with this? 关于去哪里的任何想法?

The answer: Set EnableLocation in PhoneGap.plist to NO. 答案:将PhoneGap.plist中的EnableLocation设置为NO。 Apparently, having it set to YES causes PhoneGap apps running in iOS 6 to have memory problems. 显然,将其设置为YES会导致在iOS 6中运行的PhoneGap应用程序出现内存问题。 A fix has been implemented, but as of right now, I don't think it's in the official PhoneGap release. 已经实施了修复,但截至目前,我认为它不在官方的PhoneGap版本中。 FWIW, I can't find anyone who actually knows what EnableLocation does. FWIW,我找不到任何知道EnableLocation的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM