xcode 向权限模式警报添加描述
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47749667/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add description to Permission modal alert
提问by mrisek
How to specify why the app is requesting access to the location? I would like to clarify the use of location in permission modal alert.
如何指定应用程序请求访问该位置的原因?我想澄清在许可模式警报中使用位置。
回答by Sandeep Bhandari
Just go to your info.plist
and add the following keys
只需转到您的info.plist
并添加以下键
String that you provide to these keys will be picked appropriately by iOS to show the message of the dialog when you request for user permission to access the location.
String that you provide to these keys will be picked appropriately by iOS to show the message of the dialog when you request for user permission to access the location.
Which message will be picked will be decided dynamically based on what kind of permission you are asking for. Eg : when you ask for Location Always permission its corresponding message will be picked and vice versa when you use location when in use.
将根据您要求的权限类型动态决定选择哪条消息。例如:当您请求位置始终许可时,将选择其相应的消息,反之亦然,当您在使用时使用位置。
Hope it helps
希望能帮助到你
回答by Jeetendra Kumar
Open your plist with source code, and add below
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Message for Always and when used desc</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Message for Always used desc</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Message for when used desc</string>
回答by Tim
For iOS Devices you need to specifiy NSLocationAlwaysUsageDescription
or NSLocationWhenInUseUsageDescription
directly in your Info.plist file in xCode. After that iOS will automatically manage to show your specified message in an alert.
对于 iOS 设备,您需要在 xCode中的 Info.plist 文件中指定NSLocationAlwaysUsageDescription
或NSLocationWhenInUseUsageDescription
直接指定。之后,iOS 将自动设法在警报中显示您指定的消息。