【问题标题】:Flutter iOS webview app with Geolocation website doesn't Ask For Location Permission even info.plist is adjusted带有地理位置网站的 Flutter iOS webview 应用程序不会询问位置权限,即使 info.plist 已调整
【发布时间】:2021-09-15 12:09:22
【问题描述】:

我正在尝试使用需要位置权限才能使用地理定位 javascript 的网站制作 webview 应用程序。我尝试了一些快速的方法来启用,但不幸的是无法管理它。 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,
          ),

info.plist

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

【问题讨论】:

    标签: ios flutter webview permissions geolocation


    【解决方案1】:

    您需要在 Swift 端检查位置授权状态,如果未确定,您需要在打开 web 视图之前请求它。像这样的:

    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
        }
    }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-25
    • 2018-03-02
    • 2018-07-18
    • 1970-01-01
    • 1970-01-01
    • 2021-02-04
    • 2018-09-17
    • 1970-01-01
    相关资源
    最近更新 更多