简体   繁体   English

ios ionic app中的Mapbox位置请求提示

[英]Mapbox location request prompt in ios ionic app

I have a React app that I'm turning into a phone app with Ionic and capcitorjs.我有一个 React 应用程序,我正在将它变成一个带有 Ionic 和 capcitorjs 的电话应用程序。 A mapbox map is a big part of the app and when you open the app, it requests permission to access the phone's location with a pretty normal prompt. mapbox 地图是该应用程序的重要组成部分,当您打开该应用程序时,它会以非常正常的提示请求访问手机位置的权限。 This is fine, and the map centers on the user properly (using @capacitor/geolocation) when the app is opened.这很好,当应用程序打开时,地图正确地以用户为中心(使用@capacitor/geolocation)。 But when the user pushes the mapboxgl.GeolocateControl button that centers on the user and adds the blue location dot, the prompt is strange and I don't see where to change it.但是当用户按下以用户为中心的 mapboxgl.GeolocateControl 按钮并添加蓝色位置点时,提示很奇怪,我看不到在哪里更改它。 The prompt to use the user's location (despite already having permission) is:使用用户位置的提示(尽管已经有权限)是:

"://" Would Like To Use Your Current Location "://" 想使用您当前的位置

Don't Allow |不允许 | Ok好的

Where can I change this prompt?我在哪里可以更改此提示? It does not appear on Android so this is only an iOS problem.它不会出现在 Android 上,所以这只是一个 iOS 问题。 For the first prompt to request geolocation access, that is editable in the Info.plist file in XCode, but this "Would Like..." prompt doesn't even appear in the Info.plist.对于请求地理定位访问的第一个提示,可以在 XCode 的 Info.plist 文件中编辑,但是这个“Would Like...”提示甚至没有出现在 Info.plist 中。 It seems to be caused by mapbox.这似乎是由mapbox引起的。 Can the prompt be changed with @capacitor/geolocation?可以用@capacitor/geolocation 更改提示吗?

Here are the relevant dependencies for this npm app:以下是此 npm 应用程序的相关依赖项:

"ionic": "^5.4.16",
"mapbox-gl": "^2.5.1",
"@capacitor/core": "^3.2.4",
"@capacitor/geolocation": "^1.1.0",
"@mapbox/mapbox-sdk": "^0.13.2",
"react": "^17.0.2",
"@capacitor/android": "^3.2.4",
"@capacitor/app": "^1.0.3",
"@capacitor/cli": "^3.2.4",
"@capacitor/ios": "^3.2.4",

ios has two type of geo location permissions ios 有两种地理位置权限

  1. one time use location permission (next time it will again ask for permission)一次使用位置权限(下次它会再次请求权限)
  2. when app use (it requires when app is running mode) the third permission is always which not allowed in ios 12当应用程序使用时(它需要在应用程序运行模式下)第三个权限总是在 ios 12 中不允许的

Solution :解决方案 :

in xcode info.plist add these two properties在 xcode info.plist 添加这两个属性

NSLocationAlwaysUsageDescription

NSLocationWhenInUseUsageDescription 

and some text in there string value以及字符串值中的一些文本

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

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