iOS中,访问系统隐私权限时修改alert文案的方法

2024-03-20 07:58

本文主要是介绍iOS中,访问系统隐私权限时修改alert文案的方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

开发过程中,难免会涉及到访问相册、相机、麦克风、通讯录等需要进行隐私权限授权的功能。

系统默认的alert比较生硬,像下图这样:



其实我们是可以向其中加入自定义的文案的。

加入之后看上去会更友好,像下图这样:



方法很简单,只需要向info.plist里加一行键值就行了。

例如修改通讯录权限的,Key为NSContactsUsageDescription(或 Privacy - Contacts Usage Description),Value写入你想要添加的文案就可以了。


附上官方文档地址,其它权限的键可以在里面找。

https://developer.apple.com/library/mac/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html


Table 1  Summary of Cocoa keys

Key

Xcode name

Summary

Platforms

GKGameCenterBadgingDisabled

(none)

Specifies whether your app is badged. See GKGameCenterBadgingDisabled for details.

iOS 7.0 and later

GKShowChallengeBanners

(none)

Specifies whether banners are shown within an app. See GKShowChallengeBannersfor details.

iOS 7.0 and later

NSAppleScriptEnabled

“Scriptable”

Specifies whether AppleScript is enabled. See NSAppleScriptEnabled for details.

OS X

NSAppTransportSecurity

(none)

Specifies exceptions to the default strong Internet security in iOS and OS X apps and in app extensions. SeeNSAppTransportSecurity for details.

iOS 9.0 and later, OS X v10.11 and later

NSBluetoothPeripheralUsageDescription

“Privacy - Bluetooth Peripheral Usage Description”

Specifies the reason for using Bluetooth. See NSBluetoothPeripheralUsageDescription for details.

iOS 6.0 and later

NSCalendarsUsageDescription

“Privacy - Calendars Usage Description”

Specifies the reason for accessing the user’s calendars. See NSCalendarsUsageDescription for details.

iOS 6.0 and later

NSCameraUsageDescription

“Privacy - Camera Usage Description”

Specifies the reason for accessing the device’s camera. See NSLocationAlwaysUsageDescription for details.

iOS 7.0 and later

NSContactsUsageDescription

“Privacy - Contacts Usage Description”

Specifies the reason for accessing the user’s contacts. See NSContactsUsageDescription for details.

iOS 6.0 and later, OS X v10.8 and later

NSDockTilePlugIn

”Dock Tile Plugin path”

Specifies the name of app’s Dock tile plug-in, if present. See NSDockTilePlugIn for details.

OS X

NSHumanReadableCopyright

“Copyright (human-readable)”

(Localizable) Specifies the copyright notice for the bundle. See NSHumanReadableCopyright for details.

OS X

NSJavaNeeded

“Cocoa Java application”

Specifies whether the program requires a running Java VM. See NSJavaNeeded for details.

OS X

NSJavaPath

“Java classpaths”

An array of paths to classes whose components are preceded by NSJavaRoot. SeeNSJavaPath for details.

OS X

NSJavaRoot

“Java root directory”

The root directory containing the java classes. See NSJavaRoot for details.

OS X

NSLocationAlwaysUsageDescription

(none)

Specifies the reason for accessing the user’s location information. See NSLocationAlwaysUsageDescription for details.

iOS 8.0 and later, OS X v10.10 and later

NSLocationUsageDescription

“Privacy - Location Usage Description”

Specifies the reason for accessing the user’s location information. See NSLocationUsageDescription for details.

iOS 6.0 and later, OS X v10.9 and later

NSLocationWhenInUseUsageDescription

(none)

Specifies the reason for accessing the user’s location information. See NSLocationWhenInUseUsageDescription for details.

iOS 8.0 and later, OS X v10.10 and later

NSMainNibFile

“Main nib file base name”

The name of an app’s main nib file. SeeNSMainNibFile for details.

iOS, OS X

NSMicrophoneUsageDescription

“Privacy - Microphone Usage Description”

Specifies the reason for accessing the device’s microphone. See NSCalendarsUsageDescription for details.

iOS 7.0 and later

NSMotionUsageDescription

“Privacy - Motion Usage Description”

Specifies the reason for accessing the device’s accelerometer. See NSMotionUsageDescription for details.

iOS 7.0 and later

NSPersistentStoreTypeKey

“Core Data persistent store type”

The type of Core Data persistent store associated with a persistent document type. SeeNSPersistentStoreTypeKey for details.

OS X

NSPhotoLibraryUsageDescription

“Privacy - Photo Library Usage Description”

Specifies the reason for accessing the user’s photo library. See NSPhotoLibraryUsageDescription for details.

iOS 6.0 and later

NSPrefPaneIconFile

“Preference Pane icon file”

The name of an image file resource used to represent a preference pane in the System Preferences app. SeeNSPrefPaneIconFile for details.

OS X

NSPrefPaneIconLabel

“Preference Pane icon label”

The name of a preference pane displayed beneath the preference pane icon in the System Preferences app. SeeNSPrefPaneIconLabel for details.

OS X

NSPrincipalClass

“Principal class”

The name of the bundle’s main class. See NSPrincipalClass for details.

OS X

NSRemindersUsageDescription

“Privacy - Reminders Usage Description”

Specifies the reason for accessing the user’s reminders. See NSRemindersUsageDescription for details.

iOS 6.0 and later

NSServices

“Services”

An array of dictionaries specifying the services provided by an app. See NSServices for details.

OS X

NSSupportsAutomaticTermination

(none)

Specifies whether the app may be killed to reclaim memory. See NSSupportsAutomaticTermination for details.

OS X v10.7 and later

NSSupportsSuddenTermination

(none)

Specifies whether the app may be killed to allow for faster shut down or log out operations. SeeNSSupportsSuddenTermination for details.

OS X

NSUbiquitousContainer

(none)

Specifies the iCloud Drive settings for each container. See NSUbiquitousContainers for details.

iOS, OS X

NSUbiquitousContainerIsDocumentScopePublic

(none)

Specifies whether the iCloud Drive should share the contents of this container. SeeNSUbiquitousContainerIsDocumentScopePublic for details.

iOS, OS X

NSUbiquitousContainerName

(none)

Specifies the name that the iCloud Drive displays for your container. See NSUbiquitousContainerName for details.

iOS, OS X

NSUbiquitousContainerSupportedFolderLevels

(none)

Specifies the maximum number of folder levels inside your container’s Documents directory. SeeNSUbiquitousContainerSupportedFolderLevels for details.

iOS, OS X

NSUbiquitousDisplaySet

(none)

Specifies the mobile document data that the app can view. See NSUbiquitousDisplaySet for details.

iOS, OS X

NSUserActivityTypes

(none)

Specifies the user activity types that the app supports. See NSUserActivityTypes for details.

iOS, OS X

NSUserNotificationAlertStyle

(none)

Specifies whether the notification style should be banner, alert, or none. The default value is banner, which is the recommended style. SeeNSUserNotificationAlertStyle for details.

OS X

UTExportedTypeDeclarations

“Exported Type UTIs”

An array of dictionaries specifying the UTI-based types supported (and owned) by the app. SeeUTExportedTypeDeclarations for details.

iOS 5.0 and later, OS X v10.7 and later

UTImportedTypeDeclarations

“Imported Type UTIs”

An array of dictionaries specifying the UTI-based types supported (but not owned) by the app. SeeUTImportedTypeDeclarations for details.

iOS, OS X


这篇关于iOS中,访问系统隐私权限时修改alert文案的方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/828790

相关文章

Nginx设置连接超时并进行测试的方法步骤

《Nginx设置连接超时并进行测试的方法步骤》在高并发场景下,如果客户端与服务器的连接长时间未响应,会占用大量的系统资源,影响其他正常请求的处理效率,为了解决这个问题,可以通过设置Nginx的连接... 目录设置连接超时目的操作步骤测试连接超时测试方法:总结:设置连接超时目的设置客户端与服务器之间的连接

Java判断多个时间段是否重合的方法小结

《Java判断多个时间段是否重合的方法小结》这篇文章主要为大家详细介绍了Java中判断多个时间段是否重合的方法,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录判断多个时间段是否有间隔判断时间段集合是否与某时间段重合判断多个时间段是否有间隔实体类内容public class D

Python使用国内镜像加速pip安装的方法讲解

《Python使用国内镜像加速pip安装的方法讲解》在Python开发中,pip是一个非常重要的工具,用于安装和管理Python的第三方库,然而,在国内使用pip安装依赖时,往往会因为网络问题而导致速... 目录一、pip 工具简介1. 什么是 pip?2. 什么是 -i 参数?二、国内镜像源的选择三、如何

IDEA编译报错“java: 常量字符串过长”的原因及解决方法

《IDEA编译报错“java:常量字符串过长”的原因及解决方法》今天在开发过程中,由于尝试将一个文件的Base64字符串设置为常量,结果导致IDEA编译的时候出现了如下报错java:常量字符串过长,... 目录一、问题描述二、问题原因2.1 理论角度2.2 源码角度三、解决方案解决方案①:StringBui

Linux使用nload监控网络流量的方法

《Linux使用nload监控网络流量的方法》Linux中的nload命令是一个用于实时监控网络流量的工具,它提供了传入和传出流量的可视化表示,帮助用户一目了然地了解网络活动,本文给大家介绍了Linu... 目录简介安装示例用法基础用法指定网络接口限制显示特定流量类型指定刷新率设置流量速率的显示单位监控多个

Java覆盖第三方jar包中的某一个类的实现方法

《Java覆盖第三方jar包中的某一个类的实现方法》在我们日常的开发中,经常需要使用第三方的jar包,有时候我们会发现第三方的jar包中的某一个类有问题,或者我们需要定制化修改其中的逻辑,那么应该如何... 目录一、需求描述二、示例描述三、操作步骤四、验证结果五、实现原理一、需求描述需求描述如下:需要在

JavaScript中的reduce方法执行过程、使用场景及进阶用法

《JavaScript中的reduce方法执行过程、使用场景及进阶用法》:本文主要介绍JavaScript中的reduce方法执行过程、使用场景及进阶用法的相关资料,reduce是JavaScri... 目录1. 什么是reduce2. reduce语法2.1 语法2.2 参数说明3. reduce执行过程

C#中读取XML文件的四种常用方法

《C#中读取XML文件的四种常用方法》Xml是Internet环境中跨平台的,依赖于内容的技术,是当前处理结构化文档信息的有力工具,下面我们就来看看C#中读取XML文件的方法都有哪些吧... 目录XML简介格式C#读取XML文件方法使用XmlDocument使用XmlTextReader/XmlTextWr

C++初始化数组的几种常见方法(简单易懂)

《C++初始化数组的几种常见方法(简单易懂)》本文介绍了C++中数组的初始化方法,包括一维数组和二维数组的初始化,以及用new动态初始化数组,在C++11及以上版本中,还提供了使用std::array... 目录1、初始化一维数组1.1、使用列表初始化(推荐方式)1.2、初始化部分列表1.3、使用std::

oracle DBMS_SQL.PARSE的使用方法和示例

《oracleDBMS_SQL.PARSE的使用方法和示例》DBMS_SQL是Oracle数据库中的一个强大包,用于动态构建和执行SQL语句,DBMS_SQL.PARSE过程解析SQL语句或PL/S... 目录语法示例注意事项DBMS_SQL 是 oracle 数据库中的一个强大包,它允许动态地构建和执行