开发ios应用程序_iOS14中的应用程序剪辑—即时移动应用程序
开发ios应用程序
This article is a short text summary of the WWDC20 session.
本文是 WWDC20会议 的简短摘要 。
App clips were introduced in iOS 14, helping more people discover apps on the go by almost instantly downloading a part of the app to do some task.
iOS 14中引入了应用程序片段,几乎立即下载应用程序的一部分即可完成任务,从而帮助更多的人在旅途中发现应用程序。
Unlike apps, app clips can’t be opened from the home screen. They’re launched with app-clip URLs, which are handled via app clips instead of a browser. These URLs can be either embedded in NFC
tags, processed into QR code/app-clip code(which can be scanned or tapped with the power of NFC
, FYI), or just forwarded via iMessages.
与应用程序不同,无法从主屏幕打开应用程序剪辑。 它们是通过应用程序剪辑URL启动的,这些URL通过应用程序剪辑而不是浏览器进行处理。 这些URL可以嵌入NFC
标签中,可以处理为QR代码/应用剪贴代码(可以使用NFC
,FYI进行扫描或点击),也可以仅通过iMessages转发。
App Store submissions enforce that app clips must be very small in size — <10 MB. Earlier, applications needed to be installed, signed in, and set up before usage. App clips make it possible for someone to, say, scan a QR code to almost instantly download your app clip to use it, making it an overall smoother experience.
App Store提交的内容要求应用剪辑的尺寸必须非常小-<10 MB。 以前,需要在使用前安装,登录和设置应用程序。 应用程序剪辑使某人可以扫描QR码,几乎立即下载您的应用程序剪辑以使用它,从而使整体体验更加流畅。
For developers, app clips require the creation of a second application target in Xcode that contains all of the necessary code to handle the app-clip experience. This is native Swift code, written either in SwiftUI or UIKit, meaning you could use a part of your app’s existing code for your app clips.
对于开发人员而言,应用程序剪辑需要在Xcode中创建第二个应用程序目标,该目标包含处理应用程序剪辑体验的所有必需代码。 这是用SwiftUI或UIKit编写的本机Swift代码,这意味着您可以将应用程序现有代码的一部分用于应用程序剪辑。
App clips are an additive feature to apps — meaning you need an app to make an app clip. App clips can’t be submitted to the App Store on their own. They need to be submitted as part of the app review process.
应用程序剪辑是应用程序的附加功能,这意味着您需要一个应用程序才能制作应用程序剪辑。 无法将应用片段单独提交到App Store。 他们需要在应用审核过程中提交。
App clips in iOS 14 and apps are mutually exclusive — it’s possible to download the app clip without downloading the entire app, which is the whole point. However, if the app is already installed, the app clip URL will open up the relevant part of the application instead of downloading the app clip.
iOS 14和应用程序中的应用程序剪辑是互斥的-可以下载应用程序剪辑而无需下载整个应用程序,这很重要。 但是,如果已经安装了应用程序,则应用程序剪辑URL将打开应用程序的相关部分,而不是下载应用程序剪辑。
One app can have only one app clip —the URLs can be configured to open up specific parts of the app.
一个应用程序只能有一个应用程序剪辑-可以将URL配置为打开应用程序的特定部分。
应用程序剪辑的应用程序设计 (App Design for App Clips)
Unlike applications — which contain a tab-bar controller, allowing the user to navigate between different screens — app clips should omit top-level navigation elements like tab bars, instead directing users toward a single flow, thereby allowing the user to perform a specific task per URL.
与包含标签栏控制器,允许用户在不同屏幕之间导航的应用程序不同,应用程序剪辑应省略诸如标签栏之类的顶级导航元素,而应将用户引向单个流程,从而允许用户执行特定任务每个网址。
For multiple experiences, there could be multiple URLs — each URL opening up a streamlined flow.
对于多种体验,可以有多个URL-每个URL都可以简化流程。
Also, the dependency of app clips on, say, a user’s location can be deferred. For example, if the user is trying to check out items from a physical store, instead of asking the user for their location to locate the store they’re in, the URL of that store could be configured such that the app clip knows which store the user is in.
同样,可以推迟应用剪辑对用户位置的依赖。 例如,如果用户尝试从实体商店中检出商品,而不是询问用户位置来找到他们所在的商店,则可以配置该商店的URL,以便应用程序剪辑知道哪个商店用户正在使用。
The part of code common between app and app clip can have both app and app-clip targets selected under Target Membership in the Identity Inspector. For sharing image assets, you could create a shared-asset catalog with similar modifications in target memberships, ensuring both the app and the app clip use images from the same shared folder.
在应用程序和应用程序剪辑之间通用的部分代码可以在身份检查器的“目标成员身份”下选择应用程序和应用程序剪辑目标。 为了共享图像资产,您可以创建一个共享资产目录,并对目标成员资格进行类似的修改,以确保应用程序和应用程序剪辑都使用同一共享文件夹中的图像。
You might have a class that you need in your app but not in your app clip, and if the code common to both of them uses that class, it’d lead to a build error. In that case, you’d need to conditionally compile out the references to that class by creating a custom condition in the Build Settings > Swift Compiler -Custom Flags section for both debug and release.
您可能在应用程序中有一个需要的类,但在应用程序剪辑中却没有,并且如果这两个类的通用代码都使用该类,则会导致生成错误。 在这种情况下,您需要通过在调试和发布的Build Settings> Swift Compiler -Custom Flags部分中创建自定义条件,来有条件地编译出对该类的引用。
And then, we can conditionally compile out references to the object that aren’t to be included in the app clip with:
然后,我们可以使用以下命令有条件地编译出不包含在应用程序剪辑中的对象的引用:
#if !APPCLIP //Code which runs on app but not on appClip#endif
#if !APPCLIP //Code which runs on app but not on appClip#endif
App clips can use all of the frameworks in the iOS SDK, but access to sensitive data is limited. Frameworks like HealthKit will always return negative for isHealthDataAvailable
(boolean denoting access to health data) when running as an app clip. So it’s expected for the main app to check for access to data before trying to use it. If that’s done, the app clip will run just fine.
应用程序剪辑可以使用iOS SDK中的所有框架,但是对敏感数据的访问受到限制。 当作为应用程序剪辑运行时,诸如HealthKit之类的框架对于isHealthDataAvailable
(布尔值表示对健康数据的访问)将始终返回负数。 因此,期望主应用在尝试使用数据之前先检查对数据的访问。 如果完成,该应用程序剪辑将正常运行。
Once the user uses the app clip and installs the full-fledged app, the experience can be made seamless by autofilling data from the app clip to the full-fledged app with a shared-data container. Though this isn’t compulsory, it’s highly recommended.
一旦用户使用应用程序剪辑并安装了完整的应用程序,就可以通过使用共享数据容器将数据从应用程序剪辑自动填充到完整的应用程序中,从而实现无缝的体验。 尽管这不是强制性的,但强烈建议您这样做。
有关App-Clip生命周期的更多信息 (More on the App-Clip Life Cycle)
App clips run when needed — when the app isn’t installed and an app-clip experience is opened. And after a period of inactivity, they’re automatically deleted along with data related to that app clip. App clips are also not included in an iCloud backup.
应用程序剪辑在需要时运行-未安装应用程序且打开了应用程序剪辑体验。 闲置一段时间后,它们会与与该应用程序剪辑相关的数据一起自动删除。 应用剪辑也未包含在iCloud备份中。
An app clip can be deleted anytime after inactivity. The data stored is also deleted along with any keychain data. This stored data should hence be thought of as temporarily cached data unless the data is stored in a shared-data container and the user also installs the full-fledged app before the app clip is deleted.
闲置后可以随时删除应用剪辑。 存储的数据也会与所有钥匙串数据一起删除。 因此,除非将数据存储在共享数据容器中,并且用户在删除应用程序剪辑之前还安装了完整功能的应用程序,否则应将其视为临时缓存的数据。
If the user uses the app clip on a regular basis, the app clip might never be deleted. The cached data in prior sessions can be used in the next sessions — for example, past orders can be used for recommending future orders if the app clip is designed for shopping in a local brick-and-mortar shop.
如果用户定期使用该应用程序剪辑,则该应用程序剪辑可能永远不会被删除。 先前会话中的缓存数据可在下一个会话中使用-例如,如果该应用程序剪辑旨在在本地实体店购物,则过去的订单可用于推荐将来的订单。
应用剪辑体验 (The App-Clip Experience)
Apple wants app clips to be fast, straight to the point, include as few privacy concerns as possible, and cause the least amount hindrance possible.
苹果希望应用程序剪辑能够快速,直截了当地,包括尽可能少的隐私问题,并尽可能减少障碍。
Hence, access to personal data is limited. The app clip can prompt users to download the full app if it needs access the restricted data.
因此,对个人数据的访问受到限制。 如果需要访问受限制的数据,则该应用程序剪辑可以提示用户下载完整的应用程序。
For payments, it’s recommended to use Apple Pay since the user won’t need to key in card details or worry about its security.
对于付款,建议使用Apple Pay,因为用户无需输入卡详细信息或担心其安全性。
Signing up should be made optional because instead of enjoying the experience, the user would be forced to key in their details. Instead, it could be presented after the user has completed the experience, with ‘Sign in as Apple’.
注册应该是可选的,因为用户不能享受体验,而不得不输入他们的详细信息。 相反,它可以在用户完成体验后显示为“以Apple登录”。
To convert the app clip user to installing the full app, SKOverlay
can be used — or an App Store overlay modifier in the case of a SwiftUI app.
要将应用剪辑用户转换为安装完整的应用程序,可以使用SKOverlay
或对于SKOverlay
应用程序,可以使用App Store覆盖修饰符。
总结 (To Summarize)
App clips, introduced in iOS 14, are a great way for new users to experience a section of your application. They won’t be shown in the home screen but can be invoked with URLs on iMessage, Apple’s app-clip code, or as banners on Safari.
iOS 14中引入的应用程序剪辑是新用户体验应用程序部分的*佳方法。 它们不会显示在主屏幕上,但可以使用iMessage上的URL,Apple的应用剪辑代码或作为Safari上的横幅广告来调用。
One app can have only one app clip; however, it can show multiple experiences via different URLs. Coded either in SwiftUI or UIKit, you can have the same code for the app as the app clip, which is just an extension for the app. App-clip size should be smaller than 10 MB when submitting it to the review process.
一个应用程序只能有一个应用程序剪辑; 但是,它可以通过不同的URL显示多种体验。 使用SwiftUI或UIKit进行编码,您可以为应用程序使用与应用程序剪辑相同的代码,这只是应用程序的扩展。 将应用剪辑的大小提交给审核过程时,应小于10 MB。
The small size of the app, along with predefined flows, makes it easy for users to experience a section of your app smoothly, thus giving you an opportunity to convert them into an app install.
应用程序的小尺寸以及预定义的流程,使用户可以轻松顺畅地体验应用程序的一部分,从而使您有机会将其转换为应用程序安装。