无法使用 PhoneGap 的地理定位 API;始终使用 Safari。出现难看的地理位置提示
我有一个 Sencha 应用程序,它执行地理定位,并根据结果提供附近场地的列表。
我正在使用 PhoneGap:Build (自动化服务);这一点可能很重要。我根本不处理 PhoneGap 文件 - 我让 PhoneGap:Build 自动为所有平台创建应用程序。到目前为止,情况非常壮观。
问题:据我所知,在触发“deviceready”之前尝试进行地理定位可能会导致使用 Safari 地理定位而不是设备地理定位进行地理定位调用。我遇到的副作用是这个可怕的消息提示:
'/var/mobile/Applications/XXXX-XXXX-XXXX-XXXXXXXXXXX/AppName.app/www/index.html would like to use your current location'
现在,即使我引入了 10 秒的延迟,这种情况仍然会发生 - 足够长以确保 PhoneGap 早已加载。这就是我困惑的地方。这只发生在 iOS 中; Android 构建看起来不错。
为什么我会收到此消息?我的 config.xml 中有以下行:
<feature name="http://api.phonegap.com/1.0/geolocation"/>
..我认为这足以打开 PhoneGap 地理定位 API,从而避免出现此可怕的消息。
我还应该注意到,我收到了双重提示;第一次执行地理定位时,我得到以下信息:
'App Name would like to use your location'
然后是第二条消息 - 我上面概述的丑陋的消息。
为什么连续显示两个提示?为什么不只是第一个?我花了好几天的时间在这上面……完全没有想法。请帮忙!
I have a Sencha app which performs geolocation, and provides a list of nearby venues based on the results.
I am using PhoneGap:Build (the automated service); this point might be of importance. I am not dealing with the PhoneGap files at all - I am letting PhoneGap:Build automatically create the apps for all platforms. So far it has been spectacular.
The problem: I understand that attempting to geolocate before 'deviceready' is triggered may result in a geolocation call using the Safari geolocation instead of the device geolocation. The side-effect I am experiencing is this terrible message prompt:
'/var/mobile/Applications/XXXX-XXXX-XXXX-XXXXXXXXXXX/AppName.app/www/index.html would like to use your current location'
Now, this is still happening after I introduce even a 10 second delay - long enough to ensure that PhoneGap has long since been loaded. This is where I am confused. This only happens in iOS; Android build seems fine.
Why am I getting this message? I have the following line in my config.xml:
<feature name="http://api.phonegap.com/1.0/geolocation"/>
..Which I figured was sufficient to open up the PhoneGap geolocation API, thus avoiding this horrible message.
I should also note that I get double prompted; the first time geolocation is performed, I get this:
'App Name would like to use your location'
Which is then followed by a second message - the ugly one I outlined above.
Why are two prompts being displayed back-to-back? Why not just the first one? I've spent days on this.. completely out of ideas. Please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
同样的问题已得到解决
此处。
基本上他们又带你去了
此处。
这解释了一个相当深入的过程,但至少它有效。
This same issue is addressed
here.
Basically they again take you
here.
which explains a fairly in depth process but at least it works.