简体   繁体   English

wkwebview与位置服务

[英]wkwebview with location services

Ive been experimenting with swift and wanted to try out the wkwebview. 我一直在试验swift并想尝试wkwebview。 Ive built an app and it all works correctly but the problem is that the webpage that i load into my wkwebview uses google maps and requires location services, so the javascript should prompt a message saying "this app requires your location information". 我已经构建了一个应用程序,它一切正常,但问题是我加载到我的wkwebview的网页使用谷歌地图,并需要位置服务,所以javascript应提示一条消息说“这个应用程序需要您的位置信息”。 The swift app wkwebview doesnt display any message doesnt display my google maps either. swift应用程序wkwebview不显示任何消息也不显示我的谷歌地图。 If i visit the url with the safari browser it prompts the location message and also in uiwebview on ios 7 it promps that message. 如果我使用safari浏览器访问url它会提示位置消息,并且在ios 7上的uiwebview中它会提示该消息。 Anyone else come accross this and know a solution? 还有其他人来这个并知道解决方案吗?

In iOS 8, you need to have a key in your Info.plist that the system can use to prompt for location usage. 在iOS 8中,您需要在Info.plist中有一个密钥,系统可以使用该密钥来提示位置使用情况。 In your case you want to add a key/value pair with key NSLocationWhenInUseUsageDescription . 在您的情况下,您希望使用密钥NSLocationWhenInUseUsageDescription添加密钥/值对。 The value of that pair will be shown in the first popup, from the system, asking if your app can access location services. 该对的值将显示在系统的第一个弹出窗口中,询问您的应用是否可以访问位置服务。 Then Google Maps will be allowed to pop up its own alert. 然后,谷歌地图将被允许弹出自己的警报。

的Info.plist

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Swift中为WKWebView启用位置服务? - How to enable Location Services for a WKWebView in Swift? 是否可以在 WKWebView 中关闭位置权限? - Is it possible to turn off location permission in WKWebView? WKWebView 线程 1:使用位置时发出 SIGABRT 信号 - WKWebView Thread 1: signal SIGABRT when using location WKWebview ".html 想要使用您当前的位置" 拦截不起作用 - WKWebview ".html Would Like To Use Your Current Location" Intercept not work Nativescript位置服务未更新我的仪表板 - Nativescript location services not updating my dashboard 检测用户是否在域上启用了位置服务 - Detect if user has enabled location services on domain 使用位置服务的移动网页-在位置服务关闭时为用户提供指向设置的本机链接 - Mobile webpage using location services - give user native link to setting when location services are off 为什么javascript'window.location.hash'在ios11的WKWebview中不起作用? - Why javascript 'window.location.hash' does not work in WKWebview in ios11? 有没有办法检测移动设备是否启用了JavaScript启用的位置服务? - Is there a way to detect whether or not mobile device has location services enabled with JavaScript? 当位置服务关闭时,navigator.gelocation 在 iOS 上仍然为真 - navigator.gelocation still true on iOS when location services are off
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM