我正在尝试与一个网站,这需要位置许可使用地理定位javascript的网页浏览应用程序。我在swift侧尝试了一些东西来启用它,但不幸的是无法管理它。wkwebview-app-doesnt-ask-for-location-permission
在flutter方面,我已经通过使用flutter_webview_plugin启用了地理定位和javascript,我已经在flutter中添加了同样的东西。我需要做什么才能获得许可并为网站启用位置?提前感谢
child: WebviewScaffold(
//mediaPlaybackRequiresUserGesture: true,
debuggingEnabled: true,
url: 'https://nakliyemvar.com/isveren/giris.php',
scrollBar: false,
//hidden: true,
withZoom: false,
withJavascript: true,
geolocationEnabled: true,
//withLocalUrl: true,
appCacheEnabled: true,
),
info.plist
<key>NSLocationAlwaysUsageDescription</key>
<string>asd</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>asd.</string>
发布于 2021-07-05 00:43:37
您需要检查Swift侧的位置授权状态,如果没有确定,您需要在打开webview之前请求它。如下所示:
private func manageLocationPermission() {
let authorizationStatus = CLLocationManager.authorizationStatus()
switch authorizationStatus {
case .notDetermined:
CLLocationManager().requestAlwaysAuthorization()
case .authorizedAlways, .authorizedWhenInUse:
// Open the webview
case .denied:
// Notify the user about it
case .restricted:
break
}
}
https://stackoverflow.com/questions/68243795
复制相似问题