×
广告

App Programming Guide for iOS <2.Expected App Behaviors>

96
鋼鉄侠
2016.09.24 14:14* 字数 8710

App Programming Guide for iOS翻译

https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ExpectedAppBehaviors/ExpectedAppBehaviors.html#//apple_ref/doc/uid/TP40007072-CH3-SW2

Expected App Behaviors

译:应用程序行为期望

Every new Xcode project comes configured to run right away in iOS Simulator or on a device. But simply being able to run on a device does not mean that your app is ready to ship on the App Store. Every app requires some amount of customization to ensure a good experience for the user. Customizations can range from providing an icon for your app to making architectural-level decisions about how your app presents and uses information. This chapter describes the behaviors that all apps are expected to handle and that you should consider early in the planning process.

译:每一个新Xcode项目为在iOS模拟器或设备上运行进行了配置。但是仅仅能够在设备上运行并不意味着你的应用程序已经可以提交给app Store。每个应用程序都需要一定数量自定义内容,以确保给用户良好的用户体验。自定义内容范围可以从为你的应用程序提供一个icon到做出如何呈现你的应用程序和使用信息的层次结构的策略。本章节描述了所有应用程序在规划前期过程中被期望处理的行为,。

Providing the Required Resources

译:提供必需的资源

Every app you create must have the following set of resources and metadata so that it can be displayed properly on iOS devices:

译:每一个你制作的app必须拥有以下的资源和基本数据,以便app能够正常地显示在iOS设备中:

  • An information property-list file. The Info.plist file contains metadata about your app, which the system uses to interact with your app. Xcode creates this file for you automatically based on your project’s configuration and settings. If you want to view or modify the contents of this file directly, you can do so from the Info tab of your project. For information about editing this file and for recommendations about what keys you should include, see The Information Property List File.

译:一个信息属性列表文件Info.plist。Info.plist文件包含关于应用程序的基本信息,系统用来管理你的应用程序。Xcode根据你的项目的配置和设置为您自动创建这个文件。如果你想直接查看或修改这个文件的内容,可以从项目的信息选项卡。编辑这个文件的信息或应该包括什么key,推荐你看Info.plist。

  • A declaration of the app’s required capabilities. Every app must declare the hardware capabilities or features that it requires to run. The App Store uses this information to determine whether or not a user can run your app on a specific device. You can edit your app’s list of requirements using the Required device capabilities entry in the Info tab of your project. For information on how to configure this key, see Declaring the Required Device Capabilities.

译:应用程序性能要求声明。每个应用程序都必须声明它需要运行的硬件性能或功能。App Store使用这些信息来确定用户是否可以在特定的设备上运行你的应用程序。您可以在项目信息选项卡中编辑你的应用程序使用所需的设备性能要求。关于如何配置key,看文档Declaring the Required Device Capabilities。

  • One or more icons. The system displays your app icon on the home screen of a user’s device. The system may also use other versions of your icon in the Settings app or when displaying the results of a search. For information about how to specify app icons, see App Icons.

译:一个或多个图标。系统显示你的应用图标在用户的设备主屏上。系统也可以在设置应用程序或显示一个搜索的结果时使用其他版本的图标。关于如何指定应用程序图标,请参阅App Icons。

  • One or more launch images. When an app is launched, the system displays a temporary image until the app is able to present its user interface. This temporary image is your app’s launch image and it provides the user with immediate feedback that your app is launching and will be ready soon. You must provide at least one launch image for your app and you may provide additional launch images to address specific scenarios. For information about creating your launch images, see App Launch (Default) Images.

译:一个或多个启动图像。当应用程序启动时,系统显示一个临时图像,直到它的用户界面呈现。这个临时图像是应用程序的启动图像和为用户提供即时反馈,说明你的应用程序正在启动和很快就准备好。您必须为您的应用程序提供至少一个启动画面和你可能会提供额外的启动图像来处理特定的场景。关于创建启动图像信息,请参阅App Launch (Default) Images。

These resources are required for all apps but are not the only ones you should include. There are many keys that Xcode does not include in your app’s Info.plist file by default. Most of the additional keys are important only if you incorporate specific features into your app. For example, an app that uses the microphone should include the NSMicrophoneUsageDescription key and provide the user with information about how the app intends to use it.

译:所有应用程序都需要这些资源,并不是只有你的app才拥有。有许多key在Xcode默认情况下不包含在你的应用程序Info.plist文件中。当你要导入系统一些特殊功能时,你需要添加一些key才能使用这些特殊的功能。例如,当你的应用程序需要使用麦克风时,你应该将NSMicrophoneUsageDescription这个key添加到Info.plist中去,才能提供给用户告诉用户如何去使用麦克风。

The App Bundle

译:应用程序Bundle包

When you build your iOS app, Xcode packages it as a bundle. A bundle is a directory in the file system that groups related resources together in one place. An iOS app bundle contains the app executable file and supporting resource files such as app icons, image files, and localized content. Table 1-1 lists the contents of a typical iOS app bundle, which for demonstration purposes is called MyApp. This example is for illustrative purposes only. Some of the files listed in this table may not appear in your own app bundles.

译:当你编译你的iOS应用程序时,Xcode将它打包为一个bundle包。bundle包是在文件系统中将相关资源组织在一个地方的一个目录。一个iOS应用程序bundle包包含应用程序可执行文件和资源支持文件(比如应用程序图标、图像文件和本地化内容)。表1 - 1列出了典型的iOS应用程序(示范应用程序MyApp)bundle包的内容。这个示例仅为示范用。这个表中列出的一些文件可能不会出现在你自己的应用程序bundle包里。

Table 1-1 A typical app bundle

File (文件) Example(范例) Description (描述)
App executable MyApp The executable file contains your app’s compiled code. The name of your app’s executable file is the same as your app name minus the .app extension.This file is required.
The information property list file Info.plist The Info.plist file contains configuration data for the app. The system uses this data to determine how to interact with the app. This file is required and must be called Info.plist. For more information, see The Information Property List File.
App icons Icon.png、Icon@2x.png、Icon-Small.png、Icon-Small@2x.png Your app icon is used to represent your app on the device’s Home screen. Other icons are used by the system in appropriate places. Icons with @2x in their filename are intended for devices with Retina displays.An app icon is required. For information about specifying icon image files, see App Icons.
Launch images Default.png、Default-Portrait.png、Default-Landscape.png The system uses this file as a temporary background while your app is launching. It is removed as soon as your app is ready to display its user interface. At least one launch image is required. For information about specifying launch images, see App Launch (Default) Images.
Storyboard files or nib files MainBoard.storyboard Storyboards contain the views and view controllers that the app presents on screen. Views in a storyboard are organized according to the view controller that presents them. Storyboards also identify the transitions (called segues) that take the user from one set of views to another.The name of the main storyboard file is set by Xcode when you create your project. You can change the name by assigning a different value to the UIMainStoryboardFile key in the Info.plist file.) Apps that use nib files instead of storyboards can replace the UIMainStoryboardFile key with the NSMainNibFile key and use that key to specify their main nib file.The use of storyboards (or nib files) is optional but recommended.
Ad hoc distribution icon iTunesArtwork If you are distributing your app ad hoc, include a 512 x 512 pixel version of your app icon. This icon is normally provided by the App Store from the materials you submit to iTunes Connect. However, because apps distributed ad hoc do not go through the App Store, your icon must be present in your app bundle instead. iTunes uses this icon to represent your app. (The file you specify should be the same one you would have submitted to the App Store, if you were distributing your app that way.)The filename of this icon must be iTunesArtwork and must not include a filename extension. This file is required for ad hoc distribution but is optional otherwise.>
Settings bundle Settings.bundle If you want to expose custom app preferences through the Settings app, you must include a settings bundle. This bundle contains the property list data and other resource files that define your app preferences. The Settings app uses the information in this bundle to assemble the interface elements required by your app.This bundle is optional. For more information about preferences and specifying a settings bundle, see Preferences and Settings Programming Guide.>
Nonlocalized resource files sun.png mydata.plist Nonlocalized resources include things like images, sound files, movies, and custom data files that your app uses. All of these files should be placed at the top level of your app bundle.>
Subdirectories for localized resources en.lproj fr.lproj es.lproj Localized resources must be placed in language-specific project directories, the names for which consist of an ISO 639-1 language abbreviation plus the .lproj suffix. (For example, the en.lproj, fr.lproj, and es.lproj directories contain resources localized for English, French, and Spanish.)An iOS app should be internationalized and have a language.lproj directory for each language it supports. In addition to providing localized versions of your app’s custom resources, you can also localize your app icon, launch images, and Settings icon by placing files with the same name in your language-specific project directories.For more information, see Internationalizing Your App.>

译:Table 1-1 典型应用程序bundle包

文件 Example Description
App executable MyApp 可执行文件包含app编译后的代码。您的应用程序的可执行文件的名称是跟你的程序名字去掉.app扩展后一致。这个文件是必需的
The information property list file Info.plist 属性列表文件包含应用程序的配置数据信息。系统使用该数据去管理app。这文件是必须的,而且必须起名为Info.plist。有关更多信息,请参见Info.plist文件。
App icons Icon.png、Icon@2x.png、Icon-Small.png、Icon-Small@2x.png 应用程序图标在设备上的主屏幕上用于代表你的应用程序。其他图标被系统在适当时候使用。包含@2x文件名的图标是为视网膜显示器而准备的。一个应用程序图标是必需的。更多图标图像文件的说明信息,请参阅App Icons。
Launch images Default.png、Default-Portrait.png、Default-Landscape.png 在应用程序启动时系统使用这个文件作为一个临时的背景,在你的应用准备显示用户界面时移除。要求至少有一个启动画面是。关于更多指定启动图像信息,请参阅App Launch (Default) Images。
Storyboard files or nib files MainBoard.storyboard 故事板包含用来在屏幕上显示应用的视图和视图控制器。视图在故事板中是通过视图控制器来组织呈现在屏幕上的。故事板还定义场景过渡(称为segue),将用户从一组视图场景到跳转另一个场景中去。主要故事板的名称是当您创建您的项目时由Xcode创建的。你可以改变这个名字并通过在Info.plist文件中的UIMainStoryboardFile key分配一个其它值。当应用程序使用nib文件而不是故事板时,可以用NSMainNibFile key代替UIMainStoryboardFile key并指定主要nib文件名。使用故事板(或nib文件)是可选的,但是建议您这样做。
Ad hoc distribution icon iTunesArtwork 当你上传应用程序时提供Ad hoc文件,它是一个包括一个512 x 512像素版本的应用程序图标。这个图标一般是链接iTunes时由应用商店才提供的。然而,由于应用提交ad hoc 没有通过应用商店,你的图标必须由你的应用程序bundle包代替。iTunes使用这个图标来表示应用程序。(您所指定的文件应该是一样的你会提交给应用程序商店,如果你是分发应用程序。)这个图标的文件名必须为iTunesArtwork和且不包括文件扩展名。这个文件需要临时分配但是是可选的。
Settings bundle Settings.bundle 如果你想在app设置选项中显示自定义应用程序的偏好设置,那么你需要这个Settings bundle文件。这个文件包含一个属性列表数据和其它资源文件来定义你的偏好设置。app设置选项用bundle里面的信息去添加app接口元素。这个bundle是可选的,更多关于参数和如何配置settings bundle,请看Preferences and Settings Programming Guide
Nonlocalized resource files sun.png、mydata.plist 非局限资源包括图像、声音文件、电影,和你的应用程序使用的自定义数据文件。所有这些文件应放置在应用程序bundle包的顶层。
Subdirectories for localized resources en.lproj fr.lproj es.lproj 本地化资源必须放在特定的语言项目文件夹中,名字必须由ISO 639-1语言缩写加上 .lproj 后缀组成. (比如, en.lproj、fr.lproj、es.lproj 文件 代表 English, French, Spanish本地化资源)。iOS应用程序被国际化的时,它应该包含支持每一种语言的“语言.lproj”文件夹。除了提供本地化版本的应用程序的自定义资源,您还可以本地化应用程序图标,启动图像,通过将具有相同名称的文件和设置图标在您的特定于语言的项目目录。有关更多信息,请参见 Internationalizing Your App。

For more information about the structure of an iOS app bundle, see Bundle Programming Guide. For information about how to load resource files from your bundle, see Resource Programming Guide.

译:更多的iOS应用程序bundle包的结构信息,请看Bundle Programming Guide。关于如何从bundle包里加载资源文件,请看Resource Programming Guide。

The Information Property List File

译:信息属性列表文件

Xcode uses information from the General, Capabilities, and Info tabs of your project to generate an information property list (Info.plist) file for your app at compile time. The Info.plist file is a structured file that contains critical information about your app’s configuration. It is used by the App Store and by iOS to determine your app’s capabilities and to locate key resources. Every app must include this file.

译:Xcode将你项目中的通用、性能和信息选项卡中的信息生成的一个信息属性列表(Info.plist)文件去为您的应用程序编译时使用。Info.plist文件是一个结构化的文件,其中包含关于你的应用程序的配置的重要信息。App Store和iOS根据这个文件来决定你的应用程序的功能和指定关键资源。每个应用程序都必须包括这个文件。

Although the Info.plist file provided by Xcode includes default values for all of the required entries, most apps require some changes or additions. Whenever possible, use the General and Capabilities tabs to specify the configuration information for your app. Those tabs contain the most common configuration options available for apps. If you do not see a specific option on either of those tabs, use the Info tab.

译:尽管Xcode提供的 Info.plist 文件包括所有必需条目的默认值,大多数应用程序需要进行一些修改或添加。尽可能为你的app使用通用和功能选项卡指定的配置信息。这些选项卡包含最常见的可用于应用程序配置选项。如果您没有看到这些标签上的特定选项,请使用Info选项卡。

For options where Xcode does not provide a custom configuration interface, you must provide appropriate keys and values directly using the Xcode property list editor. The Custom iOS Target Properties section of the Info tab contains a summary of the entries to be included in the Info.plist file. By default, Xcode displays human-readable descriptions of the intended feature but each feature actually corresponds to a unique key in the Info.plist file. Most keys are optional and used infrequently, but there are a handful of keys that you should consider when defining any new project:

译:有一些选项Xcode没有提供一个自定义的配置接口,您必须直接使用属性列表编辑器来提供合适的key及value。自定义iOS target属性组Info选项卡包含部分的概要条目保存在Info.plist文件中。默认情况下,Xcode显示人类可读的描述目标特征但实际上每个特性在Info.plist文件中有对应一个唯一key。大多数key是可选的且很少使用,但也有少数的key你应该在定义新工程时考虑进去。

  • Declare your app’s required capabilities in the Info tab. The Required device capabilities section contains information about the device-level features that your app requires to run. The App Store uses the information in this entry to determine the capabilities of your app and to prevent it from being installed on devices that do not support features your app requires. For more information, see Declaring the Required Device Capabilities.

译:在Info选项卡中声明你的应用程序需要的性能。设备性能要求选项组包含你的app要求运行所需的设备功能信息。App Store使用这个条目中的信息来确定应用程序的功能,防止您的应用程序被安装在设备不支持所需要的功能。有关更多信息,请参见Declaring the Required Device Capabilities。

  • Apps that require a persistent Wi-Fi connection must declare that fact. If your app talks to a server across the network, you can add the Application uses Wi-Fi entry to the Info tab of your project. This entry corresponds to the UIRequiresPersistentWiFi key in the Info.plist file. Setting this key to YES prevents iOS from closing the active Wi-Fi connection when it has been inactive for an extended period of time. This key is recommended for all apps that use the network to communicate with a server.

译:应用程序需要一个持久的wi - fi连接必须声明这一事实。如果你的应用程序与服务器通过网络,你可以添加应用使用wi - fi信息的选项卡进入您的项目。这个条目对应的UIRequiresPersistentWiFi key信息写入到Info.plist文件中。这个key设置为YES时,当应用程序处于不活跃状态时,防止系统关闭活跃的wi - fi连接并让它持续一段时间。这key是适合所有应用程序使用网络与服务器进行通信。

  • Newsstand apps must declare themselves as such. Include the UINewsstandApp key to indicate that your app presents content from the Newsstand app.

译:新闻杂志应用必须声明自己是这样:包含UINewsstandApp表明你的应用呈现的内容是来自新闻杂志应用的。

  • Apps that define custom document types must declare those types. Use the Document Types section of the Info tab to specify icons and UTI information for the document formats that you support. The system uses this information to identify apps capable of handling specific file types. For more information about adding document support to your app, see Document-Based App Programming Guide for iOS.

译:应用程序自定义文档类型必须声明为那样的类型:使用Info选项卡中的文档类型组去指定你所提供icons和UTI信息的文档格式 。系统使用这些信息来确定应用程序能够处理特定的文件类型。关于添加文档支持应用程序的更多信息,请参见Document-Based App Programming Guide for iOS.。

  • Apps can declare any custom URL schemes they support. Use the URL Types section of the Info tab to specify the custom URL schemes that your app handles. Apps can use custom URL schemes to communicate with each other. For more information about how to implement support for this feature, see Using URL Schemes to Communicate with Apps.

译:应用程序可以声明任何自定义URL方案支持。使用Info选项卡中的URL类型组来指定你app要处理的URL方案。应用程序可以使用自定义URL方案相互沟通。为更多的信息关于如何实现支持这个特性,请参看Using URL Schemes to Communicate with Apps。

  • Apps must provide purpose strings (sometimes called “usage descriptions”) for accessing user data and certain app features. When there is a privacy concern about an app accessing user data or device capabilities, iOS prompts the user and requests permission on behalf of your app. An app must explain to the user, by way of a purpose string defined in its Info.plist file, why it requires access. If your app attempts to gain access without having provided a corresponding purpose string, your app exits.

译:应用程序必须提供目的字符串(有时称为“使用说明”)来访问用户数据和某些应用程序功能。当有隐私涉及到应用程序访问用户数据或设备性能时,iOS提示用户及请求用户的许可,应用程序通过Info.plist文件中的目的字符串解释给用户知道,为什么需要访问。如果你的应用程序试图访问却不提供相应的目的字符串,应用程序将退出。

The data and features that require user permission are described in Table 1-2. Purpose strings are described in the Cocoa Keys chapter of Information Property List Key Reference.

译:需要用户权限许可的数据和功能如表1 - 2所示。目的字符串描述的信息参考Information Property List Key Reference中的Cocoa Keys章节。

For detailed information about the keys and values you can include in the Info.plist file, see Information Property List Key Reference.

译:关于你可以包含在Info.plist文件中的key和value的详细信息请参考Information Property List Key Reference.。

Declaring the Required Device Capabilities

译:声明设备性能要求

All apps must declare the device-specific capabilities they need to run. Xcode includes a Required device capabilities entry in your project’s Info tab and populates it with some minimum requirements. You can add values to this entry to specify additional requirements for your app. The Required device capabilities entry corresponds to the UIRequiredDeviceCapabilities key in your app’s Info.plist file.

译:所有应用程序都必须声明他们所需要的设备特殊性能要求。Xcode在 Info选项卡中包括了您的项目所需的设备性能及最低要求。您可以将value添加到该条目中指定应用程序额外的要求。所需的设备能力条目对应于Info.plist中的UIRequiredDeviceCapabilities key。

The value of the UIRequiredDeviceCapabilities key is either an array or dictionary that contains additional keys identifying features your app requires (or specifically prohibits). If you specify the value of the key using an array, the presence of a key indicates that the feature is required; the absence of a key indicates that the feature is not required and that the app can run without it. If you specify a dictionary instead, each key in the dictionary must have a Boolean value that indicates whether the feature is required or prohibited. A value of true indicates the feature is required and a value of false indicates that the feature must not be present on the device. If a given capability is optional for your app, do not include the corresponding key in the dictionary.

译:UIRequiredDeviceCapabilities key的value是一个数组或字典,里面包含应用程序需要(或特别禁止)附加的key定义。如果你使用一个数组指定key的value,那么key所对应的功能是必须的。没有定义的key,那么不是必须的,没有也可以运行。如果你用一个字典来指定,字典中每一个key对应的value是一个布尔类型来指定哪些功能是必须的,哪些功能是禁止的。布尔值为true时功能是必须的,false时功能必须被禁止。如果某个性能是可选的话,不要将对应的key包含进字典里。

For detailed information on the values you can include for the UIRequiredDeviceCapabilities key, see Information Property List Key Reference.

译:关于UIRequiredDeviceCapabilities key的value详细信息,请参考Information Property List Key Reference。

App Icons

译:App图标

Every app must provide an icon to be displayed on a device’s Home screen and in the App Store. An app may actually specify several different icons for use in different situations. For example, an app can provide a small icon to use when displaying search results and can provide a high-resolution icon for devices with Retina displays.

译:每个应用程序都必须提供一个图标来显示在设备上的主屏幕和显示在App Store上。应用程序可以指定不同的图标在不同情况下使用。例如,应用程序可以提供一个小图标显示搜索结果时使用,和可以提供高分辨率图标在视网膜显示设备上使用。

New Xcode projects include image asset entries for your app’s icon images. To add icons, assign the corresponding image files to the image assets of your project. At build time, Xcode adds the appropriate keys to your app’s Info.plist file and places the images in your app bundle.

译:新的Xcode项目为您的应用程序的图标图片提供一个image asset包供存放。添加图标,将相应的图像文件分配给image asset包。在编译时,Xcode将相对应的key添加到您的应用程序Info.plist 文件里和将图片资源放到你app bundle里。

For information about designing your app icons, including the sizes of those icons, see iOS Human Interface Guidelines.

译:关于如何设计你的app图标,包含哪几种尺寸图标。请参考iOS Human Interface Guidelines

App Launch (Default) Images

译:App启动(默认)图片

When the system launches an app for the first time on a device, it temporarily displays a static launch image on the screen. This image is your app’s launch image and it is a resource that you specify in your Xcode project. Launch images provide the user with immediate feedback that your app has launched while giving your app time to prepare its initial user interface. When your app’s window is configured and ready to be displayed, the system swaps out the launch image for that window.

译:当系统第一次启动应用程序时,它暂时在屏幕上显示静态启动图像。这张图片是你的应用的启动图片和在Xcode项目中被指定的资源。启动图片为用户提供即时反馈,告诉用户应用已经启动且正在准备初始化用户界面。当你的应用程序的窗口配置好和准备显示时,系统显示窗口互换掉启动图片。

When a recent snapshot of your app’s user interface is available, the system prefers the use of that image over the use of your app’s launch images. The system takes a snapshot of your app’s user interface when your app transitions from the foreground to the background. When your app returns to the foreground, it uses that image instead of a launch image whenever possible. In cases where the user has killed your app or your app has not run for a long time, the system discards the snapshot and relies once again on your launch images.

译:当应用程序的用户界面的即时快照可用时,系统将即时快照图像更换掉启动图片。当你的应用程序从前台转换到后台运行时,系统取得一个用户界面的即时快照。当你的应用程序返回到前台运行时,它尽可能使用即时快照而不是启动图像。在用户关闭你的应用程序或应用程序很长一段时间没有运行,系统就会丢弃即时快照,再次启动app时将使用你的启动图片。

New Xcode projects include image asset entries for your app’s launch images. To add launch images, add the corresponding image files to the image assets of your project. At build time, Xcode adds the appropriate keys to your app’s Info.plist file and places the images in your app bundle.

译:新的Xcode项目在image asset中包括你的应用程序的启动图片。添加启动图片时,将相应的图片文件添加到image asset。在编译时,Xcode将对应的key添加到您的应用程序的Info.plist文件中和将图片放在app bundle里。

For information about designing your app’s launch images, including the sizes of those images, see iOS Human Interface Guidelines.

译:关于如何设计你的启动图片和各种尺寸,请参考 iOS Human Interface Guidelines.

Supporting User Privacy

译:支持用户隐私

Designing for user privacy is important. Most iOS devices contain personal data that the user might not want to expose to apps or to external entities. If your app accesses or uses data inappropriately, the user might respond by deleting your app.

译:用户隐私设计很重要。很多iOS设备包含用户不想提供给app或其他实体知道的个人数据。如果你的app不适当地访问或使用那些数据,用户可能会删掉你的app。

Access user or device data only with the user’s informed consent obtained in accordance with applicable law. In addition, take appropriate steps to protect user and device data and be transparent about how you use it. Here are some best practices that you can take:

译:访问用户或设备数据只有依照适用法律得到用户的知情并且同意。此外,如何采取适当措施保护用户和设备数据,这里有一些最佳实践,您可以尝试一下:

  • Review guidelines from government or industry sources, including the following documents:

译:从政府或业内人士获得审查指南,包括下列文件:

- The Federal Trade Commission’s report on mobile privacy: Mobile Privacy Disclosures: Building Trust Through Transparency.

译:联邦贸易委员会在移动隐私方面的报告:手机隐私披露:通过建立互信。
- The EU Data Protection Commissioners’ Opinion on data protection for Mobile Apps: http://ec.europa.eu/justice/data-protection/article-29/documentation/opinion-recommendation/files/2013/wp202_en.pdf

译:欧盟数据保护专员对移动应用的数据保护的意见:http://ec.europa.eu/justice/data-protection/article-29/documentation/opinion-recommendation/files/2013/wp202_en.pdf
- The Japanese Ministry of Internal Affairs and Communications’ Smartphone Privacy Initiatives:
- Smartphone Privacy Initiative (2012):
English:http://www.soumu.go.jp/main_sosiki/joho_tsusin/eng/presentation/pdf/Initiative.pdf
Japanese: http://www.soumu.go.jp/main_content/000171225.pdf

译:日本内部事务部门和智能手机通讯隐私举措:

  • The California State Attorney General’s recommendations for mobile privacy: Privacy on the Go: Recommendations for the Mobile Ecosystem

译:加州首席检察官对手机隐私的建议:隐私和措施:移动生态系统建议

These reports provide helpful recommendations for protecting user privacy. You should also review these documents with your company’s legal counsel.

译:这些报告提供有用的建议来保护用户隐私。你还应该与贵公司的法律顾问审查这些文件。

  • Request access to sensitive user or device data, which is protected by the iOS system authorization settings, at the time your app needs the data. You must supply a purpose string (sometimes called a usage description string) in your app’s Info.plist file explaining why your app needs the data or resource you are attempting to access. Data protected by iOS system authorization settings includes location, contacts, calendar events, reminders, photos, media, and many other types as well; see Table 1-2. Provide reasonable fallback behavior in situations where the user does not grant access to the requested data.

译:当你的应用程序需要请求访问由iOS系统授权保护设置的用户或设备敏感的数据时,你必须在你的应用程序Info.plist文件中提供一个目的字符串(有时称为使用描述字符串)来解释为什么你的应用程序需要试图访问这些数据或资源。由iOS系统授权保护的数据包括位置、联系人、日历事件、提醒、照片、媒体,以及许多其他类型,见表1 - 2。当用户不授权访问所请求的数据时请提供合理的应变行为。

  • Be transparent with users about how their data is going to be used. For example, when you submit your app to the App Store, specify a URL for your privacy policy or statement as part of your iTunes Connect metadata. You might also want to summarize that policy or statement in your app description.
    For more information about providing your app’s privacy policy in iTunes Connect, see Adding an App in iTunes Connect.

译:对于用户,用户的数据将如何被使用是要求公开透明的。例如,当你提交你的应用程序到应用程序商店,指定一个URL链接作为你的隐私策略或者作为您的iTunes连接元数据的一部分。您可能还想概述隐私政策或声明应用程序描述。关于在iTunes连接提供应用程序隐私政策的更多信息,请参考Adding an App in iTunes Connect。

  • Give the user control over their user or device data. Provide settings so that the user can disable access to certain types of sensitive information as needed.

译:给用户控制自己的用户数据或设备数据。提供设置,以便用户可以禁用访问特定类型的敏感信息。

  • Request and use the minimum amount of user or device data needed to accomplish a given task. Do not seek access to or collect data for non obvious reasons, for unnecessary reasons, or because you think it might be useful later.

译:请求和使用所需最少的用户数据或设备数据完成给定的任务。没有明显理由不得寻求获得或收集数据,包括一些不必要的理由或者你觉得以后可能有用的理由。

  • Take reasonable steps to protect the user and device data that you collect in your apps. When storing such information locally, try to use the iOS data protection feature (described in Protecting Data Using On-Disk Encryption) to store it in an encrypted format. Use App Transport Security (as described in NSAppTransportSecurity) when sending user or device data over the network.

译:采取合理的步骤保护用户在你的应用程序中收集的用户数据和设备数据。当这些信息本地存储,尝试使用iOS数据保护功能(请参考Protecting Data Using On-Disk Encryption)将它存储在一个加密的格式。在网络上当用户或设备发送数据使用应用程序安全性传输(如NSAppTransportSecurity所述)。

  • If your app uses the ASIdentifierManager class, you must respect the value of its advertisingTrackingEnabled property. And if that property is set to NO by the user, then use the ASIdentifierManager class only for Limited Advertising Purposes. “Limited Advertising Purposes” means frequency capping, attribution, conversion events, estimating the number of unique users, advertising fraud detection, debugging for advertising purposes only, and other uses for advertising that may be permitted by Apple in Documentation for the Ad Support APIs.

译:如果你的应用程序使用ASIdentifierManager类,你必须注重它的advertisingTrackingEnabled属性的值。如果用户设置属性为NO,然后只能在“Limited Advertising Purposes”使用ASIdentifierManager类。“Limited Advertising Purposes”是指关于频繁哄抬价格诱骗、冒名侵权、信仰改变、调试等广告目的。其他广告使用在苹果关于Ad Support APIs中规定。

  • If you have not already done so, stop using the unique device identifier (UDID) provided by the uniqueIdentifier property of the UIDevice class. That property was deprecated in iOS 5.0, and the App Store does not accept new apps or app updates that use that identifier. Instead, apps should use the identifierForVendor property of the UIDevice class or the advertisingIdentifier property of the ASIdentifierManager class, as appropriate.

译:如果您还没有这样做,停止使用设备标识符(UDID,UIDevice类的属性,设备唯一的标识符)。在iOS 5.0,该标识符被弃用,App Store不接受使用该标识符来上传新的app序或app更新。相反,应用程序应该适当地使用UIDevice类的identifierForVendor属性或ASIdentifierManager类的advertisingIdentifier属性。

  • If your app supports audio input, configure your audio session for recording only at the point where you actually plan to begin recording. Do not configure your audio session for recording at launch time if you do not plan to record right away. The system alerts users when apps configure their audio session for recording and gives the user the option to disable recording for your app.

译:如果您的应用程序支持音频输入,只在你开始录音时配置您的音频会话录制。如果你不打算马上录制,在app启动时不会去配置您的音频会话录制。系统会在你的app配置音频会话录制时提示用户是否允许录音功能有效。

Table 1-2 lists the types of resource and data authorizations supported by iOS. For each item, the table shows the purpose-string key and the API to use to check authorization status.

译:表1-2列出iOS支持的资源和数据的授权类型。对于每个项目,表显示了目的字符串的key键和用来检查授权状态的API。

Important: When your app attempts to use a protected item, the system prompts the user with an alert asking for permission for access. Starting in iOS 10, your Info.plist file must include a purpose string, for display in the permission alert, for each such item. If your app attempts to access a protected item without you having provided a corresponding purpose string, your app exits.

译:重要:当应用程序试图使用一个受保护的项目,系统用一个警告来提示用户访问许可。从iOS 10开始,对于每一次这样的项目,你的Info.plist文件必须包括目的字符串在允许警告中显示。如果你的应用程序试图访问受保护的项目没有你有提供相应的目的字符串,程序将退出。

For some protected data and resources, iOS frameworks provide dedicated API for checking and requesting authorization, as described in Table 1-2.Because a user can change authorization at any time by using Settings, check authorization status before accessing any of these items. (Some features, notably motion and HomeKit, do not provide dedicated API for checking system authorization status. See Table 1-2 for details.)

译:对于一些受保护的数据和资源,iOS框架提供专用的API,用于检查和请求授权,如表1 - 2所示。因为用户可以在任何时候通过设置改变授权,访问这些项目之前检查授权状态(一些特性,特别是运动和HomeKit,不提供用于检查系统授权状态专用的API。有关详细信息,请参阅表1 - 2)。

Table 1-2 Data and resources protected by system authorization settings

译:表1 - 2 受系统授权保护设置的数据和资源列表

Data or resources Purpose-string Info.plist keys System authorization APIs
Bluetooth peripherals NSBluetoothPeripheralUsageDescription Use the state property of the CBCentralManager class to check system-authorization status for using Bluetooth peripherals>
Calendar data NSCalendarsUsageDescription Use the authorizationStatusForEntityType: method of the EKEventStore class to check system-authorization status for accessing calendar data.>
Camera NSCameraUsageDescription Use the deviceInputWithDevice:error: method of the AVCaptureDeviceInput class to check system-authorization status for using device cameras.>
Contacts NSContactsUsageDescription Use the authorizationStatusForEntityType: method of the CNContactStore class to check system-authorization status for accessing contact data.>
Health sharing NSHealthShareUsageDescription Use the authorizationStatusForType: method of the HKHealthStore class to check system-authorization status for accessing health data.To request authorization, use the requestAuthorizationToShareTypes:readTypes:completion: method.>
Health updating NSHealthUpdateUsageDescription Use the authorizationStatusForType: method of the HKHealthStore class to check system-authorization status for accessing health data.To request authorization, use the requestAuthorizationToShareTypes:readTypes:completion: method.>
HomeKit NSHomeKitUsageDescription When your app first attempts to access a property of the HMHomeManager class, the system presents an authorization request to the user.>
Location NSLocationAlwaysUsageDescription, NSLocationWhenInUseUsageDescription Use the authorizationStatus method of the CLLocationManager class to check system-authorization status for accessing location data.To request authorization, use the requestWhenInUseAuthorization or the requestAlwaysAuthorization method.>
Microphone NSMicrophoneUsageDescription Use the recordPermission method of the AVAudioSession class to check system-authorization status for using device microphones.To request authorization, use the requestRecordPermission: method.>
Motion NSMotionUsageDescription Check for a CMErrorNotAuthorized error from the queryActivityStartingFromDate:toDate:toQueue:withHandler: method of the CMMotionActivityManager class to check system-authorization status for accelerometer access.
Music and the media library NSAppleMusicUsageDescription Use the authorizationStatus method of the ALAssetsLibrary class to check system-authorization status for accessing media assets.>
Photos NSPhotoLibraryUsageDescription Use the authorizationStatus method of the PHPhotoLibrary class to check system-authorization status for accessing the photo library.>
Reminders NSRemindersUsageDescription Use the authorizationStatusForEntityType: method of the EKEventStore class to check system-authorization status for accessing reminder data.>
Siri NSSiriUsageDescription Use the siriAuthorizationStatus method of the INPreferences class to check system-authorization status for using Siri.To request authorization for your app to use SiriKit, use the requestSiriAuthorization: method.>
Speech recognition NSSpeechRecognitionUsageDescription Use the authorizationStatus authorizationStatus method of the SFSpeechRecognizer class to check system-authorization status for using speech recognition.To request authorization for your app to use speech recognition, use the requestAuthorization method.>
TV provider NSVideoSubscriberAccountUsageDescription Use the checkAccessStatusWithOptions:completionHandler: method of the VSAccountManager class to check system-authorization status for accessing the user’s video service subscription information.To request authorization, use the enqueueResourceAuthorizationRequest:completionHandler: method.

资源和数据 Info.plist 中的目的字符串key 系统授权 APIs
蓝牙外设 NSBluetoothPeripheralUsageDescription 使用CBCentralManager类的状态属性来检查蓝牙外设系统授权状态
日历数据 NSCalendarsUsageDescription 使用EKEventStore类的authorizationStatusForEntityType:方法来检查系统日历数据授权访问状态。
相机 NSCameraUsageDescription 使用AVCaptureDeviceInput类的deviceInputWithDevice:error:方法为摄像头设备使用前检查系统授权状态。
联系人 NSContactsUsageDescription 使用CNContactStore类的authorizationStatusForEntityType:方法来检查联系人数据的系统授权访问状态。
健康数据分享 NSHealthShareUsageDescription 使用HKHealthStore类的authorizationStatusForType:方法来检查健康数据系统授权访问的状态。请求授权,使用requestAuthorizationToShareTypes:readTypes:completion:方法。
健康数据更新 NSHealthUpdateUsageDescription 使用HKHealthStore类的authorizationStatusForType:方法来检查健康数据系统授权访问的状态。请求授权,使用requestAuthorizationToShareTypes:readTypes:completion:方法。
HomeKit NSHomeKitUsageDescription 当你的应用程序试图第一次访问HMHomeManager类的属性时,系统向用户提供了一个授权请求。
位置 NSLocationAlwaysUsageDescription, NSLocationWhenInUseUsageDescription 使用CLLocationManager类的authorizationStatus 方法来检查位置数据系统授权访问的状态。请求授权,使用requestWhenInUseAuthorization或requestAlwaysAuthorization方法。
麦克风 NSMicrophoneUsageDescription 使用AVAudioSession类的recordPermission 方法来检查麦克风使用系统授权的状态。请求授权,使用requestRecordPermission:方法。
运动 NSMotionUsageDescription 使用CMMotionActivityManager类的queryActivityStartingFromDate:toDate:toQueue:withHandler: 方法检查CMErrorNotAuthorized为加速度计访问检查系统授权状态。
音乐和媒体库 NSAppleMusicUsageDescription 使用ALAssetsLibrary类的authorizationStatus方法来检查访问媒体库的系统授权。
相片 NSPhotoLibraryUsageDescription 使用PHPhotoLibrary类的authorizationStatus 方法检查访问照片库系统授权的状态。
提醒 NSRemindersUsageDescription 使用EKEventStore类的authorizationStatusForEntityType:方法检查访问提醒数据系统授权状态。
Siri NSSiriUsageDescription 使用INPreferences类的siriAuthorizationStatus方法来检查使用Siri系统授权的状态。应用程序使用requestSiriAuthorization:方法请求siri使用。
语音识别 NSSpeechRecognitionUsageDescription 使用SFSpeechRecognizer类的authorizationStatus 方法来检查使用语音识别系统授权的状态。应用程序使用requestAuthorization方法请求语音识别使用授权。
TV 提供者信息 NSVideoSubscriberAccountUsageDescription 使用VSAccountManager类的checkAccessStatusWithOptions:completionHandler:方法来检查访问用户的视频服务订阅信息系统授权状态。使用enqueueResourceAuthorizationRequest:completionHandler:方法请求授权。

View Table 1-2 as a starting point for your app’s privacy behaviors and not as a comprehensive checklist. This table’s contents evolves across iOS updates.

译:查看表1 - 2作为你的应用程序的隐私行为的起点,而不是作为一个全面的检查清单。这个表的内容随iOS更新而发展。

Internationalizing Your App

译:App国际化

Because iOS apps are distributed in many countries, localizing your app’s content can help you reach many more customers. Users are much more likely to use an app when it is localized for their native language. When you factor your user-facing content into resource files, localizing that content is a relatively simple process.

译:因为iOS应用程序在许多国家发布,本地化应用程序的内容可以帮助你获取更多的用户。用户更可能使用一个为他们的母语本地化的应用程序。当你将用户面向的内容作为一个资源文件,本地化内容是一个相对简单的过程。

Before you can localize your content, you must internationalize your app in order to facilitate the localization process. Internationalizing your app involves factoring out any user-facing content into localizable resource files and providing language-specific project (.lproj) directories for storing that content. It also means using appropriate technologies (such as date and number formatters) when working with language-specific and locale-specific content.

译:在本地化内容之前,你必须国际化应用程序以方便于本地化过程处理。国际化应用程序包括将用户面向的内容分解成本地化资源文件和提供特定于语言的项目(.lproj)目录来存储内容。这也意味着使用适当的技术(比如日期和数字格式化程序)在处理特定于语言和特定内容。

For a fully internationalized app, the localization process creates new sets of language-specific resource files for you to add to your project. A typical iOS app requires localized versions of the following types of resource files:

译:为了应用完全国际化的,本地化过程包括创建新的特定语言资源文件组添加到项目中。一个典型的iOS应用程序本地化版本需要以下资源文件:

  • Storyboard files (or nib files)—Storyboards can contain text labels and other content that need to be localized. You might also want to adjust the position of interface items to accommodate changes in text length. (Similarly, nib files can contain text that needs to be localized or layout that needs to be updated.)

译:故事板文件(或nib文件)-故事板包含文本标签和其他内容需要本地化。您可能还想调整界面元素的位置,以适应文本长度的变化。(同样,nib文件包含的文本需要本地化或布局需要更新。)

  • Strings files—Strings files (so named because of their .strings filename extension) contain localized versions of the static text that your app displays.

译:字符串文件-字符串文件(这样命名是因为他们的.string文件扩展名)包含应用程序显示的本地化版本静态文本。

  • Image files—You should avoid localizing images unless the images contain culture-specific content. Whenever possible, you should avoid storing text directly in your image files. For images that you load and use from within your app, store text in a strings file and composite that text with your image-based content at runtime.

译:图像文件—应避免图像本地化,除非图像包含特殊文化内容。尽可能,你应该避免直接存储文本在你的图像文件中。当加载图像或app使用图像时,在runtime添加保存字符串文件的文本组合到基础图像上去显示。

  • Video and audio files—You should avoid localizing multimedia files unless they contain language-specific or culture-specific content. For example, you would want to localize a video file that contained a voice-over track.

译:视频和音频文件—应避免多媒体文件本地化,除非他们包含特殊语言或特殊文化内容。例如,您想要本地化一个视频文件,可以使用一个旁白发音。

For information about the internationalization and localization process, see Internationalization and Localization Guide. For information about the proper way to use resource files in your app, see Resource Programming Guide.

译:关于更多的国际化和本地化过程的信息,请参阅Internationalization and Localization Guide。关于资源文件使用的所有方式信息请参考Resource Programming Guide.

App Programming Guide for iOS
Web note ad 1