I am trying to make a webview app with a website which needs location permission to use geolocation javascript. I tried something on swift side to enable but unfortunately couldn't manage it. wkwebview-app-doesnt-ask-for-location-permission
On flutter side, I have enabled geolocation and javascript by using flutter_webview_plugin I have added same stuff to info.plist. What I have to do more to get permission and enable location for website? Thanks in advance
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>
You need to check location authorization status on Swift side and if not determined you need to request it before opening the webview. Something like this:
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
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.