添加描述到权限模式警报

mri*_*sek 8 iphone xcode ios react-native visual-studio-code

如何指定应用程序请求访问该位置的原因?我想澄清在权限模式警报中使用位置.

San*_*ari 15

只需转到您的info.plist并添加以下密钥即可

在此输入图像描述

当您请求用户访问该位置的权限时,iOS将适当地选择您提供给这些键的字符串以显示该对话框的消息.

将挑选哪条消息将根据您要求的权限进行动态决定.例如:当您在使用位置时,当您在使用时使用位置时,将会选择其相应的消息,反之亦然.

希望能帮助到你


小智 5

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>
Run Code Online (Sandbox Code Playgroud)