問題描述
有沒有人有使用cordova、html的經驗并且知道如何為iOS解決這個地理定位消息問題?我只想讓消息說出應用名稱,后跟想使用您當前的位置".
Does anyone have experience using cordova, html and know how to fix this geolocation message issue for iOS? I just want the message to say the app name followed by the line, "would like to use your current location."
當前地理位置消息:
///Users/kklsndksjladn/Library/Developer/CoreSimulator/Devices/FAF7EE4C-40BA-430A-80D5-5C84B07D970D/data/Containers/Bundle/Application/DAE305B6-C6DD-438B-B4D7-9B183A8B2D97/HelpME.app/www/index.html
///Users/kklsndksjladn/Library/Developer/CoreSimulator/Devices/FAF7EE4C-40BA-430A-80D5-5C84B07D970D/data/Containers/Bundle/Application/DAE305B6-C6DD-438B-B4D7-9B183A8B2D97/HelpME.app/www/index.html
我嘗試了堆棧溢出和其他網站的各種解決方案.我實現了 navigator.geolocation.getCurrentPosition(onSuccess, onError);
代碼,將我的 cordova.js 文件包含在每個 html 頁面中,確保 <script>src=cordova.js</script>
首先出現在我的 index.html 頁面中,在我的 config.xml 文件中包含地理定位標簽并嘗試使用我的 plist.有人請幫忙!!!!
I've tried various solutions from stack overflow and other websites. I implemented the navigator.geolocation.getCurrentPosition(onSuccess, onError);
code, included my cordova.js file in every html page, made sure <script> src=cordova.js</script>
appears first in my index.html page, included the geolocation tag in my config.xml file and tried playing around with my plist. Someone please help!!!!
-謝謝
推薦答案
除了 DaveAlden 的回答,我必須刪除舊版本的地理定位插件并添加新版本.然后我不得不刪除/添加 Cordova iOS 平臺.只有這樣我才能成功地將 NSLocationWhenInUseUsageDescription
添加到 .plist 文件中.
In addition to the answer from DaveAlden, I had to remove the old version of the geolocation plugin and add the new one. Then I had to remove/add the Cordova iOS platform. Only then could I add NSLocationWhenInUseUsageDescription
to the .plist file with success.
首先,移除/添加地理定位插件:
First, remove/add the geolocation plugin:
cordova plugin rm org.apache.cordova.geolocation
cordova plugin add org.apache.cordova.geolocation
二、移除/添加iOS平臺:
Second, remove/add the iOS platform:
cordova platform rm ios
cordova platform add ios
最后,將 NSLocationWhenInUseUsageDescription
添加到 .plist.打開 /platforms/ios/{project}/{project}-Info.plist
并添加以下內容:
Last, add NSLocationWhenInUseUsageDescription
to the .plist. Open /platforms/ios/{project}/{project}-Info.plist
and add the following:
<key>NSLocationWhenInUseUsageDescription</key>
<string>[App Name] would like to access your location when running and displayed.</string>
查看此iOS 開發者庫鏈接 了解有關 NSLocationWhenInUseUsageDescription
與 NSLocationAlwaysUsageDescription
與 NSLocationUsageDescription
的詳細信息.
See this iOS Developer Library link for detailed information regarding NSLocationWhenInUseUsageDescription
versus NSLocationAlwaysUsageDescription
versus NSLocationUsageDescription
.
使用 Cordova 的 iPhone 上的位置權限警報可能是重復的.
這篇關于修復 Cordova Geolocation 請求位置消息的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!