admin管理员组文章数量:1334953
I have a Phonegap
app. I am including cordova.js
in the HTML (but not in the www
directory), I am waiting for deviceready
to be fired, and then I'm calling
navigator.geolocation.getCurrentPosition(successCallback,failCallback);
I'm receiving both versions of the dialog (in this order):
Native Dialog - .png
HTML Dialog - .png
I have a Phonegap
app. I am including cordova.js
in the HTML (but not in the www
directory), I am waiting for deviceready
to be fired, and then I'm calling
navigator.geolocation.getCurrentPosition(successCallback,failCallback);
I'm receiving both versions of the dialog (in this order):
Native Dialog - https://i.sstatic/H5y1O.png
HTML Dialog - https://i.sstatic/XbcmR.png
4 Answers
Reset to default 5If you're using version 3+ of PhoneGap, make sure you're correctly including the plugin.
From the PhoneGap v3.0.0 API Docs :
As of version 3.0, Cordova implements device-level APIs as plugins. Use the CLI's plugin mand, described in The Command-line Interface, to add or remove this feature for a project
I had the same problem, that's because there was not successfully installed phonegap geolocation plugin. Do you know how install it? Please check how to on http://docs.phonegap./en/3.0.0/guide_cli_index.md.html#The%20Command-line%20Interface
Do not call getCurrentPosition immediately after deviceready has been fired. geolocation plugin is not ready, so navigator.geolocation.getCurrentPosition actually calls HTML5 api, then you see the HTML dialog. I do below to make sure geolocation plugin is ready before calling navigator.geolocation.getCurrentPosition in my ionic project.
var my_getposition = function() {
if (ionic.Platform.isIOS() && !window.Coordinates) {
$timeout(function(){ my_getposition(); }, 500);
return;
}
navigator.geolocation.getCurrentPosition(...);
}
You have to run "cordova prepare" in order to change the config.xml and it will automatically generate cordova_plugins.js that will be used for the geolocation plugin.
Just beware because when you do run cordova prepare it will erase all your /www folder.
Tipically you would have to add all the plugins and set up your environment before you add your code to the /www folder...
本文标签: javascriptiOS Use Current Location Permission dialog is shown twice in Phonegap appStack Overflow
版权声明:本文标题:javascript - iOS Use Current Location Permission dialog is shown twice in Phonegap app - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742314156a2451476.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论