Highlight
The Session was led by Charles Ying and centered around four new features: the App Clips size limit has been increased from 10MB to 15MB (iOS 16 required); a new App Clip Diagnostics diagnostic tool has been added to help troubleshoot Universal Link configuration issues; App Clips can now read CloudKit public databases; and Keychain data is automatically migrated when users install the complete App.
Core Content
The goal of App Clip is clear: users encounter a task in a restaurant, parking lot, web page, or in Messages and complete it immediately without installing the full app first.
This goal keeps developers subject to two constraints.First, the size must be small.The old 10MB cap forced you to remove assets, split functionality, and delay loading content.Second, the experience must be close to the full app.Paying, logging in, reading menus, displaying location information, these processes all require data and secure storage.
The update of WWDC 2022 pushes these two directions a step forward.iOS 16 increases the upper limit of App Clip size to 15MB; App Clip Diagnostics helps you check URL, entity code, Safari, iMessage and Universal Link configuration; CloudKit public database can be read directly; Keychain items will be migrated after the user installs the complete App.
The last piece is operational issues.Once you have advanced App Clip experience, manually creating locations, images, and localized information in App Store Connect becomes a repetitive task.App Store Connect’s App Clip experiences Web API turns this part into a scriptable process.
Detailed Content
15MB upper limit: first determine the minimum system version
(01:07) App Clips have a new 15MB limit, provided that the minimum system version of the App Clip is set to iOS 16.If you want to be compatible with iOS 15 or earlier systems, you still need to keep it within 10MB.
This change leaves room for more complex real-time tasks.For example, the food ordering App Clip can reserve more UI resources, payment process and status page.But Charles Ying also emphasized that speed is still the core of App Clip.Users are not necessarily in a high-speed network environment, and downloading additional resources after startup can reduce the initial download burden.
Conceptual decision: App Clip size target
1. If the App Clip's minimum version is iOS 16, the compressed download size can approach 15 MB.
2. If iOS 15 or earlier must be supported, the compressed download size still needs to stay within 10 MB.
3. Large resources needed only after launch should be fetched on demand after launch.
Key points:
- The 15MB limit only applies to App Clips with a minimum version of iOS 16.
- 10MB is still the limit for compatibility with iOS 15 and earlier systems.
- Downloading additional resources after startup is a supplementary strategy clearly mentioned in the speech. The specific download mechanism needs to be selected according to the App’s own architecture.
- Reducing the size does not mean that startup speed can be ignored. App Clip is still oriented to real-time scenarios.
App Clip Diagnostics: Directly point out URL configuration issues
(02:10) App Clip has many entrances: physical App Clip Code, Safari, iMessage, and Universal Link.Problems often lie between these configurations as well.If the Safari banner does not appear, or if the user clicks a link but opens the web page, there may be an issue with Associated Domains, experience configuration, or URL matching.
App Clip Diagnostics for iOS 16 is placed in the device’s Developer Settings.After connecting to Xcode, open the developer settings, enter Diagnostics of App Clips Testing, enter the URL, and the system will check the configuration.If it passes, you will see a green check; if it fails, the interface will explain the specific problem and give a link to the document.
Conceptual flow: using App Clip Diagnostics
1. Connect an iPhone or iPad to Xcode and enable Developer Settings.
2. Open Developer Settings > App Clips Testing > Diagnostics.
3. Enter the App Clip URL to test.
4. Review the configuration check results for App Clip experience, Safari, iMessage, and Universal Link.
5. Fix the configuration based on the documentation linked from failing items.
Key points:
- Diagnostics are on-device developer tools that don’t require you to integrate new code into your app.
- It checks for App Clip experiences that use physical codes, as well as Safari and iMessage.
- It also checks the Universal Link’s Associated Domains configuration.
- The failure result will explain the specific configuration steps, which is suitable for troubleshooting problems such as “the web page is opened instead of the App Clip”.
CloudKit: App Clip can read public databases
(03:27) App Clips did not work with CloudKit.If App Clip needs to read menu, product or location resources, a common approach is to connect to its own server.
Starting with iOS 16, App Clips can read CloudKit public database.In this way, the complete App and App Clip can share the same CloudKit container and the same set of reading code.The boundaries are also clear: App Clip can only read public databases and cannot write to CloudKit; nor can it use cloud documents and key-value stores.
// Read your CloudKit public database from your App Clip
let container = CKContainer.default()
let publicDatabase = container.publicCloudDatabase
let record = try await publicDatabase.record(for:
CKRecord.ID(recordName: "A928D582-9BB6-E9C5-7881-E4EAF615E0CD"))
if let title = record["Title"] as? String,
let description = record["Description"] as? String {
print("Fetched a food item from CloudKit: \(title) \(description)")
}
Key points:
CKContainer.default()Get the CloudKit container used by App Clip.container.publicCloudDatabaseExplicit access to public databases, which is the scope of App Clip support.record(for:)useCKRecord.IDPull the specified record.record["Title"]andrecord["Description"]Convert the field into a string after reading it.- This code only reads data, which conforms to the restriction of “App Clips can read from a public database but can’t write data to CloudKit” in the speech.
The enabling method is also given in the speech: open the Signing and Capabilities of the App Clip target and select the CloudKit container to be used.This container can be newly created or shared with the complete App.
Keychain migration: sensitive data does not need to be placed in the App Group first
(04:59) Data such as login token and payment information are suitable for being placed in Keychain.In the past, when App Clip was upgraded to a complete App, developers often used shared app group container for transfer: App Clip was written to the shared container, and the complete App was read after installation and then put into the Keychain.
iOS 16 corrects this detour.After the user installs the complete App, the items in the App Clip Keychain will be transferred to the complete App.App Clip can directly write security data into Keychain, and the complete App can read it using the same Keychain query code.
// Write authentication token to App Clip keychain
let addSecretsQuery: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecValueData as String: "smoothie-secret".data(using: .utf8),
kSecAttrLabel as String: "foodsample-appclip"
]
SecItemAdd(addSecretsQuery as CFDictionary, nil)
// Read authentication token from app or App Clip
var readSecretsQuery: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecReturnAttributes as String: true,
kSecAttrLabel as String: "foodsample-appclip",
kSecReturnData as String: true
]
var secretsCopy: AnyObject?
SecItemCopyMatching(readSecretsQuery as CFDictionary, &secretsCopy)
Key points:
kSecClassGenericPasswordIndicates that the general password type Keychain item is stored here.kSecValueDataSave token data, in the examplesmoothie-secretof UTF-8 data.kSecAttrLabelAdd a label to the item so that the complete app can identify that it comes from the App Clip.SecItemAddWrite Keychain in App Clip.SecItemCopyMatchingThis query code can be used to read items with the same tag, both App and App Clip.
There are boundaries here too: shared keychain groups and iCloud Keychain are not supported.This still preserves the promise of App Clips: iOS deletes an App Clip and its data when it is no longer in use.
App Clip Experiences API: Automatically create advanced experiences
(06:28) Advanced App Clip experiences are tied to information or locations.The more restaurants, stores, and parking spots there are, the harder it is to maintain them manually.The App Clip experiences web API provided by App Store Connect is used to automate the creation and updating of these experiences.
The process in the speech is divided into three steps: first obtain the App Clip resource ID through the App item ID and App Clip bundle ID; then upload the header image; and finally use the App Clip resource ID and header image ID to create an advanced App Clip experience.
# Get the App Clip resource ID
GET /v1/apps/1234567890/appClips?filter[bundleId]=com.example.foodsample.Clip
# Response
{
"data": {
"attributes": {
"bundleId": "com.example.foodsample.Clip"
},
"id": "726ad1bb-3e1b-40eb-a986-d8a9897e4f1e"
}
}
Key points:
GET /v1/apps/{appId}/appClipsLocate the app using its item ID.filter[bundleId]Narrow down with App Clip bundle ID.- in response
data.idIs the App Clip resource ID, which needs to be included in the relationship when creating an experience later. - The IDs in the examples are sample resource IDs given in the talk and should not be copied directly into real requests.
Uploading the header image is the second step.
# Upload a header image for the advanced App Clip experience
POST /v1/appClipAdvancedExperienceImages
{
"data": {
"type": "appClipAdvancedExperienceImages",
"attributes": {
"fileName": "Hero_image_US.png",
"fileSize": 43500
}
}
}
# Response
{
"data": {
"attributes": "...",
"id": "91c52741-832b-48a2-8935-1797655edbe7"
}
}
Key points:
POST /v1/appClipAdvancedExperienceImagesCreate image assets for use in advanced experiences.fileNameandfileSizeDescribe the image file to upload.- In the response,
data.idis the header image resource ID. - This ID will be used when creating advanced experiences
headerImageused in relationships.
The third step is to create an advanced App Clip experience.
# Create advanced App Clip experience
POST /v1/appClipAdvancedExperiences
{
"data": {
"type": "appClipAdvancedExperiences",
"attributes": {
"action": "OPEN",
"businessCategory": "FOOD_AND_DRINK",
"defaultLanguage": "EN",
"isPoweredBy": true,
"link": "https://fruta.example.com/restauraunt/simply_salad",
"place": {
"names": [ "Caffe Macs" ],
"mapAction": "RESTAURANT_ORDER_FOOD",
"displayPoint": {
"coordinates": { "latitude": 37.33611, "longitude": -122.00731 },
"source": "CALCULATED"
}
}
},
"relationships": {
"appClip": {
"data": {
"type": "appClip",
"id": "726ad1bb-3e1b-40eb-a986-d8a9897e4f1e"
}
},
"headerImage": {
"data": {
"type": "appClipAdvancedExperienceImages",
"id": "91c52741-832b-48a2-8935-1797655edbe7"
}
}
},
"included": {
"type": "appClipAdvancedExperienceLocalizations",
"attributes": {
"language": "EN",
"subtitle": "Fresh salad every day",
"title": "Simply Salad"
}
}
}
}
Key points:
attributes.action、businessCategory、defaultLanguageandlinkDescribe the experience itself.placeUsed to bind Maps locations, including location names, map actions and coordinates.relationships.appClipAssociate the App Clip resource ID obtained in the first step.relationships.headerImageAssociate the header image resource ID created in the second step.includedPut localized titles and subtitles, in the example they are in EnglishSimply SaladandFresh salad every day。
Core Takeaways
-
Make a CloudKit-driven lightweight menu App Clip: Put menu, product or store display data in the CloudKit public database.Why it’s worth doing: App Clip can share the reading logic with the complete App, and there is no need to maintain a separate set of server interfaces for read-only data.How to get started: Select the CloudKit container in Signing and Capabilities of the App Clip target and use
CKContainer.default().publicCloudDatabaseRead public records. -
Write App Clip login token directly into Keychain: After the user completes login or payment authorization with App Clip, save the short-term token as Keychain item.Why it’s worth doing: After the user installs the complete app, the Keychain items will be migrated there, and the complete app can continue its state.How to start: Use
SecItemAddwrite tapekSecAttrLabelitem, used in the complete appSecItemCopyMatchingQuery the same tag. -
Add URL diagnostic list for each launch: Run App Clip Diagnostics on the key App Clip URL in the real device Developer Settings before publishing.Why it’s worth doing: It can directly pinpoint issues with Safari banners, iMessage, physical experiences, and Universal Link configurations.How to start: Connect to Xcode, open Developer Settings, enter the URL of each type of entry, and use failed items as publishing blocking conditions.
-
Use scripts to batch create store App Clip experiences: Catering, parking, and reservation apps can convert store data into App Store Connect API requests.Why it’s worth doing: Advanced App Clip experience is usually tied to locations, pictures, and localized titles, and manual maintenance is prone to errors when the number grows.How to start: first call
GET /v1/apps/{appId}/appClipsGet the App Clip resource ID, then upload the header image, and finally callPOST /v1/appClipAdvancedExperiencesCreate experiences. -
Re-evaluate the minimum version strategy of App Clips: If the product requires more resources, consider setting the minimum version of App Clips to iOS 16.Why it’s worth it: The 15MB cap accommodates more complete on-the-fly processes.How to get started: Use Xcode’s size report to confirm the compressed size, and then decide whether to stay compatible with iOS 15 or trade in iOS 16 for 15MB of space.
Related Sessions
- What’s new in App Clips - Supplementary updates to the discovery, review and testing process of App Clips in iOS 15, suitable for reading before the 2022 update.
- Explore App Clips — An introductory overview of App Clips, explaining the trigger entry, life cycle, and basic development model.
- Streamline your App Clip — Explains the size, startup speed and resource splitting, directly corresponding to the 15MB upper limit and speed reminder in this session.
- Create App Clips for other businesses — Talk about how platform-based apps create App Clips for merchants, related to advanced experience batch management scenarios.
- Expanding automation with the App Store Connect API — Basic background on App Store Connect API automation to help understand the workflow of the App Clip Experiences API.
Comments
GitHub Issues · utterances