久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      • <bdo id='ySrx6'></bdo><ul id='ySrx6'></ul>

      <small id='ySrx6'></small><noframes id='ySrx6'>

    1. <legend id='ySrx6'><style id='ySrx6'><dir id='ySrx6'><q id='ySrx6'></q></dir></style></legend>

    2. <tfoot id='ySrx6'></tfoot>
      <i id='ySrx6'><tr id='ySrx6'><dt id='ySrx6'><q id='ySrx6'><span id='ySrx6'><b id='ySrx6'><form id='ySrx6'><ins id='ySrx6'></ins><ul id='ySrx6'></ul><sub id='ySrx6'></sub></form><legend id='ySrx6'></legend><bdo id='ySrx6'><pre id='ySrx6'><center id='ySrx6'></center></pre></bdo></b><th id='ySrx6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ySrx6'><tfoot id='ySrx6'></tfoot><dl id='ySrx6'><fieldset id='ySrx6'></fieldset></dl></div>

      如何防止 Phonegap 應用程序中的地理定位雙重提示

      How to prevent double prompt for geolocation in Phonegap app?(如何防止 Phonegap 應用程序中的地理定位雙重提示?)
      <legend id='ONG8b'><style id='ONG8b'><dir id='ONG8b'><q id='ONG8b'></q></dir></style></legend>

      <small id='ONG8b'></small><noframes id='ONG8b'>

      <tfoot id='ONG8b'></tfoot>
      • <bdo id='ONG8b'></bdo><ul id='ONG8b'></ul>

                <i id='ONG8b'><tr id='ONG8b'><dt id='ONG8b'><q id='ONG8b'><span id='ONG8b'><b id='ONG8b'><form id='ONG8b'><ins id='ONG8b'></ins><ul id='ONG8b'></ul><sub id='ONG8b'></sub></form><legend id='ONG8b'></legend><bdo id='ONG8b'><pre id='ONG8b'><center id='ONG8b'></center></pre></bdo></b><th id='ONG8b'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ONG8b'><tfoot id='ONG8b'></tfoot><dl id='ONG8b'><fieldset id='ONG8b'></fieldset></dl></div>
                  <tbody id='ONG8b'></tbody>

                本文介紹了如何防止 Phonegap 應用程序中的地理定位雙重提示?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我為 iPhone 創建了一個 PhoneGap 應用,它通過 webview 中的 JavaScript 使用地理定位.

                I created a PhoneGap app for iPhone that uses geolocation via JavaScript inside webview.

                當我第一次運行該應用程序時,它會提示我允許此應用程序的地理定位.

                When I run the app the first time, it'll prompt me to allow geolocation for this app.

                當我點擊ok"時,它會再次提示我同樣的問題,但這次它指出index.html"需要使用地理位置的權限.

                When I hit "ok", it'll prompt me again with the same question but this time it states that "index.html" wants permission to use geolocation.

                這是有道理的,因為 iOS 可能第一次需要允許應用程序本身的地理定位權限,而瀏覽器第二次需要權限.

                That makes sense because iOS probably wants permission to allow geolocation for the app itself for the first time and the 2nd time the browser wants permission.

                但是,因為不會帶來出色的用戶體驗:

                However, since doesn't lead to a great user experience:

                如何防止這種雙重提示?(如果可以防止第二個提示就足夠了)

                How can I prevent this double prompt? (I'd be enough if the 2nd prompt could be prevented)

                推薦答案

                我找到了問題的原因.

                navigator.geolocation.getCurrentPosition(onsuccess, onerror) 的調用發生在 Phonegap 完全加載之前.

                The call to navigator.geolocation.getCurrentPosition(onsuccess, onerror) happens before Phonegap was fully loaded.

                這意味著 webview 的地理定位調用(而不是通過 PhoneGap 的本地調用)被觸發,這將再次請求許可(這確實有意義).將其與智能手機上的普通 Safari 瀏覽器進行比較.它會要求每個新網站的地理位置許可.應用啟動時通過PhoneGap加載index.html也是一樣.

                This means that the geolocation call of webview (and not a native call via PhoneGap) is being triggered which will again ask for permission (which does make sense). Compare it to the normal Safari browser on your Smartphone. It'll ask for geolocation permission for every new website. It's the same when loading index.html via PhoneGap on application startup.

                但是,解決方案是等待在 PhoneGap 完全加載時觸發的 deviceready 事件:

                However, the solution is to wait for the deviceready event which gets fired when PhoneGap has fully loaded:

                document.addEventListener("deviceready", function(){
                     navigator.geolocation.getCurrentPosition(onsuccess, onerror, params);
                }, false);
                

                這將使 PhoneGap API 可用,它會覆蓋瀏覽器的默認 HTML5 地理定位調用,并通過本機調用(您已在第一個提示中接受)獲取設備的地理位置.

                This will make the PhoneGap API available which overwrites the default HTML5 gelocation call of the browser and get the device's geo location via a native call (which you already accepted in the first prompt).

                這會起作用,因為 PhoneGap 的 API 調用與 HTML5 的標準 W3C 調用相同:http://docs.phonegap.com/en/2.2.0/cordova_geolocation_geolocation.md.html#Geolocation

                This will work because PhoneGap's API calls are identical to the standard W3C call for HTML5: http://docs.phonegap.com/en/2.2.0/cordova_geolocation_geolocation.md.html#Geolocation

                這篇關于如何防止 Phonegap 應用程序中的地理定位雙重提示?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經度計算 X 和 Y)
                CLLocation returning negative speed(CLLocation 返回負速度)
                Locations in Core Data sorted by distance via NSFetchedResultsController?(通過 NSFetchedResultsController 按距離排序的核心數據中的位置?)
                Swift: Geofencing / geolocations near user location(Swift:用戶位置附近的地理圍欄/地理位置)
                How to get Location (latitude amp; longitude value) in variable on iOS?(如何在 iOS 上的變量中獲取位置(緯度和經度值)?)
                Calculate bearing between two locations (lat, long)(計算兩個位置之間的方位角(緯度、經度))
              1. <small id='cJiZd'></small><noframes id='cJiZd'>

                <i id='cJiZd'><tr id='cJiZd'><dt id='cJiZd'><q id='cJiZd'><span id='cJiZd'><b id='cJiZd'><form id='cJiZd'><ins id='cJiZd'></ins><ul id='cJiZd'></ul><sub id='cJiZd'></sub></form><legend id='cJiZd'></legend><bdo id='cJiZd'><pre id='cJiZd'><center id='cJiZd'></center></pre></bdo></b><th id='cJiZd'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cJiZd'><tfoot id='cJiZd'></tfoot><dl id='cJiZd'><fieldset id='cJiZd'></fieldset></dl></div>

                        • <bdo id='cJiZd'></bdo><ul id='cJiZd'></ul>
                            <tbody id='cJiZd'></tbody>
                          <tfoot id='cJiZd'></tfoot><legend id='cJiZd'><style id='cJiZd'><dir id='cJiZd'><q id='cJiZd'></q></dir></style></legend>
                        • 主站蜘蛛池模板: 麻豆久久久久 | 日韩av美女电影 | 日日夜夜天天综合 | 午夜免费电影 | 国产在线一区二区三区 | 久草精品视频 | 一区二区三区免费 | 国产在线视频一区 | 91在线导航| 久久午夜精品 | 久久高清免费视频 | 色爱综合| 99在线免费观看视频 | 第四色狠狠 | 麻豆久久久久久 | 91综合在线观看 | 欧美综合精品 | www.日韩欧美| 国产亚洲精品精品国产亚洲综合 | 91福利在线观看 | 一区二区精品视频 | av影片在线 | 日韩精品1区2区3区 爱爱综合网 | 日本三级线观看 视频 | av日日操 | 久久久久国产精品午夜一区 | 亚洲精品国产偷自在线观看 | 久久久久久国产精品久久 | 欧美精品在线一区二区三区 | 久久久久国产 | 日本精a在线观看 | 欧美午夜一区 | 99影视| 欧美一级二级视频 | 国产一区二区在线免费观看 | 久久精品国产免费一区二区三区 | 欧美精品国产一区二区 | 免费毛片网站在线观看 | 狠狠干综合视频 | 色婷婷久久久亚洲一区二区三区 | 欧美老少妇一级特黄一片 |