Aar*_*her 5 javascript geolocation ios cordova ios-permissions
我有一个 Cordova 应用程序,它做的第一件事就是在应用程序启动时检查用户的位置。问题是,如果这是用户第一次启动应用程序(在 iOS 上),地理定位插件不会等待用户对 iOS 显示的地理权限对话框说是或否。
无论如何我可以让这个插件功能等待用户说允许或禁止地理权限吗?
有问题的插件https://github.com/apache/cordova-plugin-geolocation
示例函数调用:
navigator.geolocation.getCurrentPosition(geolocationSuccess,geolocationError,geolocationOptions);
Run Code Online (Sandbox Code Playgroud)
当我第一次启动应用程序时,我收到了 iOS 权限提示,但我可以在后台看到函数调用已经进入错误函数。
KOT*_*IOS -1
它需要在 plist 中进行修改,请按照以下步骤操作,在 cordova 中添加您的平台之前应该遵循以下步骤:
步骤1:
add NSLocationWhenInUseUsageDescription to the .plist. Open /platforms/ios/{project}/{project}-Info.plist
Run Code Online (Sandbox Code Playgroud)
第 2 步:添加以下内容
<key>NSLocationWhenInUseUsageDescription</key>
<string>[App Name] would like to access your location when running and displayed.</string>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1456 次 |
| 最近记录: |