首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >带有地理定位网站的Flutter iOS webview应用程序即使调整了info.plist也不会请求定位权限

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

Stack Overflow用户
提问于 2021-07-04 18:31:28
回答 1查看 121关注 0票数 0

我正在尝试与一个网站,这需要位置许可使用地理定位javascript的网页浏览应用程序。我在swift侧尝试了一些东西来启用它,但不幸的是无法管理它。wkwebview-app-doesnt-ask-for-location-permission

在flutter方面,我已经通过使用flutter_webview_plugin启用了地理定位和javascript,我已经在flutter中添加了同样的东西。我需要做什么才能获得许可并为网站启用位置?提前感谢

代码语言:javascript
运行
复制
  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

代码语言:javascript
运行
复制
<key>NSLocationAlwaysUsageDescription</key>
<string>asd</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>asd.</string>
EN

回答 1

Stack Overflow用户

发布于 2021-07-05 00:43:37

您需要检查Swift侧的位置授权状态,如果没有确定,您需要在打开webview之前请求它。如下所示:

代码语言:javascript
运行
复制
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
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68243795

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档