繁体   English   中英

带有地理位置网站的 Flutter iOS webview 应用程序不会请求位置权限,即使 info.plist 已调整

[英]Flutter iOS webview app with Geolocation website doesn't Ask For Location Permission even info.plist is adjusted

我正在尝试使用需要位置权限才能使用地理定位 javascript 的网站制作 webview 应用程序。 我在 swift 方面尝试了一些启用但不幸的是无法管理它。 wkwebview-app-doesnt-ask-for-location-permission

在颤振方面,我通过使用flutter_webview_plugin启用了地理定位和 javascript,我向 info.plist 添加了相同的内容。 我还需要做些什么才能获得许可并为网站启用位置? 提前致谢

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

信息.plist

<key>NSLocationAlwaysUsageDescription</key>
<string>asd</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>asd.</string>

您需要在 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
    }
}

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM