久久久久久久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 應(yīng)用程序中的地理定位雙重提示

      How to prevent double prompt for geolocation in Phonegap app?(如何防止 Phonegap 應(yīng)用程序中的地理定位雙重提示?)
      <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 應(yīng)用程序中的地理定位雙重提示?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我為 iPhone 創(chuàng)建了一個 PhoneGap 應(yīng)用,它通過 webview 中的 JavaScript 使用地理定位.

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

                當(dāng)我第一次運(yùn)行該應(yīng)用程序時(shí),它會提示我允許此應(yīng)用程序的地理定位.

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

                當(dāng)我點(diǎn)擊ok"時(shí),它會再次提示我同樣的問題,但這次它指出index.html"需要使用地理位置的權(quán)限.

                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.

                這是有道理的,因?yàn)?iOS 可能第一次需要允許應(yīng)用程序本身的地理定位權(quán)限,而瀏覽器第二次需要權(quán)限.

                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.

                但是,因?yàn)椴粫沓錾挠脩趔w驗(yàn):

                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) 的調(diào)用發(fā)生在 Phonegap 完全加載之前.

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

                這意味著 webview 的地理定位調(diào)用(而不是通過 PhoneGap 的本地調(diào)用)被觸發(fā),這將再次請求許可(這確實(shí)有意義).將其與智能手機(jī)上的普通 Safari 瀏覽器進(jìn)行比較.它會要求每個新網(wǎng)站的地理位置許可.應(yīng)用啟動時(shí)通過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 完全加載時(shí)觸發(fā)的 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 可用,它會覆蓋瀏覽器的默認(rèn) HTML5 地理定位調(diào)用,并通過本機(jī)調(diào)用(您已在第一個提示中接受)獲取設(shè)備的地理位置.

                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).

                這會起作用,因?yàn)?PhoneGap 的 API 調(diào)用與 HTML5 的標(biāo)準(zhǔn) W3C 調(diào)用相同: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

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

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

                相關(guān)文檔推薦

                Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經(jīng)度計(jì)算 X 和 Y)
                CLLocation returning negative speed(CLLocation 返回負(fù)速度)
                Locations in Core Data sorted by distance via NSFetchedResultsController?(通過 NSFetchedResultsController 按距離排序的核心數(shù)據(jù)中的位置?)
                Swift: Geofencing / geolocations near user location(Swift:用戶位置附近的地理圍欄/地理位置)
                How to get Location (latitude amp; longitude value) in variable on iOS?(如何在 iOS 上的變量中獲取位置(緯度和經(jīng)度值)?)
                Calculate bearing between two locations (lat, long)(計(jì)算兩個位置之間的方位角(緯度、經(jīng)度))
              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>
                        • 主站蜘蛛池模板: 亚洲福利在线观看 | 91偷拍精品一区二区三区 | 精品videossex高潮汇编 | 天天干天天玩天天操 | 无毛av | 四虎在线视频 | 毛片区 | 国产伊人精品 | 日韩三极| 中文字幕一区二区三区在线观看 | 在线免费激情视频 | 国产精品高潮呻吟久久av黑人 | 91精产国品一二三区 | 久久久久国产精品免费免费搜索 | 免费超碰 | 亚洲欧美日韩久久 | 精品中文在线 | 亚洲精品高清视频在线观看 | 夜夜操天天操 | 国产在线永久免费 | 午夜视频一区 | 欧美αv | 黄色中文字幕 | 亚洲精品成人免费 | 69性欧美高清影院 | 日韩一级精品视频在线观看 | 国产成人免费在线 | 天天干.com | 综合国产第二页 | 亚洲精品字幕 | 欧美久久久| 日韩在线视频观看 | 久久宗合色 | 玖玖国产| 中文字幕一区二区三区四区 | 亚洲成av人影片在线观看 | 羞羞涩涩在线观看 | 国产欧美日韩精品在线观看 | 久久99视频| 国产精品日韩欧美 | 日韩精品一区二区三区四区视频 |