### Example CSV File Content for App Clip URLs Source: https://developer.apple.com/documentation/appclip/creating-app-clip-codes-with-app-store-connect This is an example of the content for a CSV file used to specify multiple invocation URLs for generating App Clip Codes. Each row represents a single App Clip Code, and each value is a URL that must match the selected App Clip experience. ```text https://appclip.example.com/about https://appclip.example.com/buy https://appclip.example.com/buy?id=123 https://appclip.example.com/buy?id=456 https://appclip.example.com/buy?id=789 ``` -------------------------------- ### On-Demand Install Capable Entitlement Source: https://developer.apple.com/documentation/AppClip A Boolean value indicating whether a bundle represents an App Clip. Set to true to enable on-demand installation for an App Clip. ```plist com.apple.developer.on-demand-install-capable ``` -------------------------------- ### Get Launch URL Source: https://developer.apple.com/documentation/appclip/apactivationpayload Access the URL that launched the App Clip. This property is optional and may be nil if the App Clip was not launched via a URL. ```swift var url: URL? ``` -------------------------------- ### Define App Clip Code URL in CSV Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar Example of a URL format used within a CSV file to associate an App Clip Code with a specific item or location. ```text https://developer.apple.com/sunfl ``` -------------------------------- ### Process Invocation URL Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar Initiate asset downloading based on the product key derived from the invocation URL. ```swift process(productKey: getProductKey(from: appClipCodeLaunchURL), initializePreview: false) ``` -------------------------------- ### Define the App entry point with SwiftUI Source: https://developer.apple.com/documentation/appclip/fruta-building-a-feature-rich-app-with-swiftui The structure conforming to the App protocol serves as the entry point for the application, managing the view hierarchy and scene presentation. ```swift @main struct FrutaApp: App { @StateObject private var model = Model() var body: some Scene { WindowGroup { ContentView() .environmentObject(model) } .commands { SidebarCommands() SmoothieCommands(model: model) } } } ``` -------------------------------- ### Process Product Model Loading Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar Initiates the process of loading a 3D model asset using a provided URL and product key. It utilizes a caching web loader for efficiency. ```swift func process(productKey: String, initializePreview: Bool = true) { if let modelURL = modelURLFor[productKey] { process(modelURL: modelURL, productKey: productKey) func process(modelURL: URL, productKey: String) { let contentLoad = CachingWebLoader.shared.cachedWebLoad(url: modelURL) ``` -------------------------------- ### APActivationPayloadErrorDomain Constant Source: https://developer.apple.com/documentation/appclip/apactivationpayloaderrordomain This constant is a string that identifies the activation payload’s error domain. It is available on iOS, iPadOS, and Mac Catalyst starting from version 14.0. ```APIDOC ## APActivationPayloadErrorDomain ### Description A string that identifies the activation payload’s error domain. ### Availability iOS 14.0+iPadOS 14.0+Mac Catalyst 14.0+ ### Declaration ```swift let APActivationPayloadErrorDomain: String ``` ### See Also - `struct APActivationPayloadError` - `enum Code` ``` -------------------------------- ### Initializers Source: https://developer.apple.com/documentation/appclip/apactivationpayload Initializes an APActivationPayload object. ```APIDOC ## init?(coder: NSCoder) ### Description Initializes an APActivationPayload object. ### Initializer `init?(coder: NSCoder)` ### Parameters - **coder** (NSCoder) - Required - The coder to use for initialization. ``` -------------------------------- ### Suggest Custom Color Pairs Source: https://developer.apple.com/documentation/appclip/creating-app-clip-codes-with-the-app-clip-code-generator Use the `suggest` command to verify custom foreground and background colors for high contrast. Replace placeholders with your RGB color's hexadecimal representation. ```bash % AppClipCodeGenerator suggest --foreground $foregroundColor --background $backgroundColor ``` ```bash % AppClipCodeGenerator suggest --foreground 65D212 --background 5B1637 ``` ```bash Foreground: FFFFFF Background: 345678 Foreground: 44DDDD Background: 345678 Foreground: 55DDFF Background: 345678 Foreground: AABBCC Background: 345678 Foreground: BBCCBB Background: 345678 Foreground: FFBBEE Background: 345678 Foreground: 33DDFF Background: 345678 Foreground: CCBB33 Background: 345678 ``` -------------------------------- ### Get App Clips errorDomain Source: https://developer.apple.com/documentation/appclip/apactivationpayloaderror/errordomain Use this property to retrieve the domain of errors for App Clips. Available on iOS 14.0+, iPadOS 14.0+, and Mac Catalyst 14.0+. ```swift static var errorDomain: String { get } ``` -------------------------------- ### Create ARReferenceImage from Packaging Image Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar Downloads a packaging image and creates an ARReferenceImage for image tracking. This is crucial for accurately placing virtual content. ```swift func process(imageURL: URL, productKey: String, initializeImageAnchor: Bool) { if initializeImageAnchor { let imageLoader = CachingWebLoader.shared.cachedWebLoad(url: imageURL) { [weak self] url in DispatchQueue.global(qos: .userInitiated).async { if let dataProvider = CGDataProvider(url: url as CFURL), let image = CGImage( jpegDataProviderSource: dataProvider, decode: nil, shouldInterpolate: false, intent: .absoluteColorimetric ) { let modelAnchorImage = ARReferenceImage( image, orientation: .up, // Note: the width of the sample seed packet is about 8cm. physicalWidth: 0.08 ) ``` -------------------------------- ### Map Product Key to 3D Model URL Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar A dictionary that maps product keys (URL suffixes) to the URLs of their corresponding 3D assets. ```swift let modelURLFor: [String: URL] = [ "sunfl": URL(string: "https://developer.apple.com/sample-code/ar/sunflower.usdz")! ] ``` -------------------------------- ### Map Product Key to Packaging Image URL Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar A dictionary that maps product keys to the URLs of their packaging images, used for placing 3D models in the AR environment. ```swift let imageURLFor: [String: URL] = [ "sunfl": URL(string: "https://developer.apple.com/sample-code/ar/sunflower.jpg")! ] ``` -------------------------------- ### Fetch App Clip Metadata and Display Preview Source: https://developer.apple.com/documentation/appclip/launching-another-app-s-app-clip-from-your-app Use `LPMetadataProvider` to fetch metadata for an App Clip's invocation URL and then display it using `LPLinkView`. This is useful for showing a rich preview before launching the App Clip. ```swift let provider = LPMetadataProvider() let url = URL(string: "https://appclip.example.com/")! var linkView = ... // A reference to the link view. This could also be a custom view that contains the LPLinkView. provider.startFetchingMetadata(for: url) { (metadata, error) in guard let metadata = metadata else { // The fetch failed; handle the error. return } DispatchQueue.main.async { // Create the LPLinkView using the metadata. If you use a custom view, you could pass the metadata to the custom view and let it handle the creation or formatting of the LPLinkView. linkView = LPLinkView(metadata: metadata) } } ``` -------------------------------- ### Launch App Clip with UIKit open(_:) Source: https://developer.apple.com/documentation/appclip/launching-another-app-s-app-clip-from-your-app For UIKit applications, use `UIApplication.shared.open(_:options:completionHandler:)` to launch an App Clip directly. This method is used when the App Clip has a default App Clip link for its default experience. ```swift func launchAppClip() { let appClipURL = URL( string: "https://appclip.apple.com/id?p=com.example.naturelab.backyardbirds.Clip" )! UIApplication.shared.open(appClipURL) } ``` -------------------------------- ### init(coder:) Source: https://developer.apple.com/documentation/appclip/apactivationpayload/init%28coder%3A%29 Initializes a new instance of APActivationPayload by decoding it from the given decoder. This method is part of the NSCoding protocol, allowing objects to be serialized and deserialized. ```APIDOC ## init(coder:) ### Description Initializes an `APActivationPayload` object from an `NSCoder`. This initializer is required when conforming to the `NSCoding` protocol for object serialization and deserialization. ### Method `init?(coder: NSCoder)` ### Parameters #### Parameters - **coder** (`NSCoder`) - The decoder to decode the object from. ### Availability iOS 14.0+ iPadOS 14.0+ Mac Catalyst 14.0+ ``` -------------------------------- ### Generate App Clip Code with Custom Colors Source: https://developer.apple.com/documentation/appclip/creating-app-clip-codes-with-the-app-clip-code-generator Generate an App Clip Code with custom foreground and background colors by using the `--foreground` and `--background` options. Provide the invocation URL and output file path. ```bash % AppClipCodeGenerator generate --url https://appclip.example.com --foreground 123456 --background FFFFFF --output ~/path/to/filename.svg ``` -------------------------------- ### APActivationPayloadError.Code.doesNotMatch Source: https://developer.apple.com/documentation/appclip/apactivationpayloaderror/code/disallowed Represents an error where the provided URL does not match the registered App Clip URL. ```APIDOC ## APActivationPayloadError.Code.doesNotMatch ### Description The provided URL doesn’t match the registered App Clip URL. ### Definition ```swift case doesNotMatch ``` ``` -------------------------------- ### APActivationPayloadError.Code.doesNotMatch Source: https://developer.apple.com/documentation/appclip/apactivationpayloaderror/code/doesnotmatch Represents an error where the provided URL does not match the registered App Clip URL. ```APIDOC ## APActivationPayloadError.Code.doesNotMatch ### Description The provided URL doesn’t match the registered App Clip URL. ### Availability - iOS 14.0+ - iPadOS 14.0+ - Mac Catalyst 14.0+ ### Definition ```swift case doesNotMatch ``` ``` -------------------------------- ### Launch App Clip with SwiftUI Link Source: https://developer.apple.com/documentation/appclip/launching-another-app-s-app-clip-from-your-app In a SwiftUI application, use the `Link` view to provide a direct link to an App Clip. This is suitable when the App Clip uses its default App Clip link for its default experience. ```swift var body: some View { let appClipURL = URL( string: "https://appclip.apple.com/id?p=com.example.naturelab.backyardbirds.Clip" )! Link("Backyard Birds", destination: appClipURL) } ``` -------------------------------- ### Add Smart App Banner and App Clip Card to Website Source: https://developer.apple.com/documentation/appclip/supporting-invocations-from-your-website-and-the-messages-app Include this HTML meta tag in your website's source code to display a Smart App Banner and the App Clip card. Replace placeholders with your App Clip's bundle ID and your app's Store ID. This enables launching the App Clip from your website. ```html ``` -------------------------------- ### Implement App Clip Code Coaching Overlay Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar A custom UILabel subclass used to display instructions when the system fails to immediately detect an App Clip Code. ```swift class AppClipCodeCoachingOverlayView: UILabel { init(parentView: UIView) { super.init(frame: .zero) text = "Scan code to start" ``` -------------------------------- ### Display an App Store overlay in UIKit Source: https://developer.apple.com/documentation/appclip/recommending-your-app-to-app-clip-users Use this function to present an App Store overlay at the bottom of the current window scene. Ensure the view is part of a valid window scene before calling. ```swift func displayOverlay() { guard let scene = view.window?.windowScene else { return } let config = SKOverlay.AppClipConfiguration(position: .bottom) let overlay = SKOverlay(configuration: config) overlay.present(in: scene) } ``` -------------------------------- ### Extract Product Key from URL Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar A utility function to extract the product key from a decoded URL by taking the last path component. ```swift func getProductKey(from url: URL) -> String { return url.lastPathComponent } ``` -------------------------------- ### APActivationPayloadError.doesNotMatch Source: https://developer.apple.com/documentation/appclip/apactivationpayloaderror/doesnotmatch Represents an error where the provided URL does not match the registered invocation URL for an App Clip. ```APIDOC ## APActivationPayloadError.doesNotMatch ### Description The provided URL doesn’t match the invocation URL you registered for the App Clip. ### Availability - iOS 14.0+ - iPadOS 14.0+ - Mac Catalyst 14.0+ ### Declaration `static var doesNotMatch: APActivationPayloadError.Code { get }` ``` -------------------------------- ### Display 3D Asset on Image Anchor Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar Call this function when ARKit recognizes an image anchor to display a virtual product on top of it. Ensure the image anchor and self are valid. ```swift if let imageAnchorForModel = self?.imageAnchorFor[productKey], let self = self { self.modelFor[productKey]!.present(on: imageAnchorForModel) ``` -------------------------------- ### Check for App Clip Code Tracking Support Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar Verify that the device supports App Clip Code tracking via the Apple Neural Engine before proceeding. ```swift guard ARWorldTrackingConfiguration.supportsAppClipCodeTracking else { displayUnsupportedDevicePrompt() return ``` -------------------------------- ### URL Instance Property Source: https://developer.apple.com/documentation/appclip/apactivationpayload/url The `url` property provides the URL of the link that launched the App Clip. This data can be used to update the App Clip's user interface. ```APIDOC ## url ### Description The URL of the link that launched the App Clip. ### Availability iOS 14.0+ iPadOS 14.0+ Mac Catalyst 14.0+ ### Property ```swift var url: URL? { get } ``` ### Discussion Use `url` to retrieve data that’s passed to an App Clip on launch, and use the data to update the user interface of the App Clip. The value of `url` is the same as the `NSUserActivity` `webpageURL` property. If you don’t need to verify the user’s location when they launch your App Clip, use `webpageURL` instead. For more information, see Responding to invocations. ``` -------------------------------- ### Default Color Pair Output Source: https://developer.apple.com/documentation/appclip/creating-app-clip-codes-with-the-app-clip-code-generator This is the output from the `templates` command, showing various default color combinations for App Clip Codes. Each entry provides an index and the hexadecimal representation of the foreground and background colors. ```text Index: 0 Foreground: FFFFFF Background: 000000 Index: 1 Foreground: 000000 Background: FFFFFF Index: 2 Foreground: FFFFFF Background: 777777 Index: 3 Foreground: 777777 Background: FFFFFF Index: 4 Foreground: FFFFFF Background: FF3B30 Index: 5 Foreground: FF3B30 Background: FFFFFF Index: 6 Foreground: FFFFFF Background: EE7733 Index: 7 Foreground: EE7733 Background: FFFFFF Index: 8 Foreground: FFFFFF Background: 33AA22 Index: 9 Foreground: 33AA22 Background: FFFFFF Index: 10 Foreground: FFFFFF Background: 00A6A1 Index: 11 Foreground: 00A6A1 Background: FFFFFF Index: 12 Foreground: FFFFFF Background: 007AFF Index: 13 Foreground: 007AFF Background: FFFFFF Index: 14 Foreground: FFFFFF Background: 5856D6 Index: 15 Foreground: 5856D6 Background: FFFFFF Index: 16 Foreground: FFFFFF Background: CC73E1 Index: 17 Foreground: CC73E1 Background: FFFFFF ``` -------------------------------- ### APActivationPayloadError.Code.disallowed Source: https://developer.apple.com/documentation/appclip/apactivationpayloaderror/code/disallowed Represents an error where the user denied location access or the invocation source was invalid. ```APIDOC ## APActivationPayloadError.Code.disallowed ### Description The user denied location access, or the source of the App Clip invocation wasn’t from an NFC tag or visual code. ### Availability - iOS 14.0+ - iPadOS 14.0+ - Mac Catalyst 14.0+ ### Definition ```swift case disallowed ``` ``` -------------------------------- ### APActivationPayloadError.Code.disallowed Source: https://developer.apple.com/documentation/appclip/apactivationpayloaderror/code/doesnotmatch Represents an error where the user denied location access or the invocation source was invalid. ```APIDOC ## APActivationPayloadError.Code.disallowed ### Description The user denied location access, or the source of the App Clip invocation wasn’t from an NFC tag or visual code. ``` -------------------------------- ### List Default Color Pairs Source: https://developer.apple.com/documentation/appclip/creating-app-clip-codes-with-the-app-clip-code-generator Run this command in the Terminal app to view a list of default color pairs for App Clip Codes. The output includes an index and hexadecimal values for foreground and background colors. ```bash % AppClipCodeGenerator templates ``` -------------------------------- ### Enable App Clip Code Tracking Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar Configure the AR session to track physical App Clip Codes by setting the tracking property to true. ```swift newConfiguration.appClipCodeTrackingEnabled = true arView.session.run(newConfiguration) ``` -------------------------------- ### Run Python Script for Batch App Clip Code Generation Source: https://developer.apple.com/documentation/appclip/creating-app-clip-codes-with-the-app-clip-code-generator Execute this command in the Terminal to generate App Clip Codes in bulk. Replace `$filename.csv` with your CSV file name and `$directory` with the target output directory. ```bash % python batch_generator.py $filename.csv $directory ``` ```bash % python batch_generator.py sample_list.csv GeneratedCodes ``` -------------------------------- ### Retrieve the App Clip launch URL Source: https://developer.apple.com/documentation/appclip/apactivationpayload/url Access the URL that triggered the App Clip launch. This property is equivalent to the webpageURL property of NSUserActivity. ```swift var url: URL? { get } ``` -------------------------------- ### APActivationPayload Initializer Source: https://developer.apple.com/documentation/appclip/apactivationpayload/init%28coder%3A%29 Initializes an APActivationPayload instance using an NSCoder. This initializer is part of the NSCoding protocol. ```swift init?(coder: NSCoder) ``` -------------------------------- ### Generate an App Clip Code Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar Use the AppClipCodeGenerator command-line tool to create an SVG file for an App Clip Code. ```bash AppClipCodeGenerator generate --url https://developer.apple.com/sunfl --index 0 --output ~/Downloads/AppClipCode-sunflower.svg --logo badge ``` -------------------------------- ### Generate Scan-Only App Clip Code Source: https://developer.apple.com/documentation/appclip/creating-app-clip-codes-with-the-app-clip-code-generator Generate a scan-only App Clip Code using the `generate` command with the `--index` option for a default color pair. Specify the invocation URL and output file path. ```bash % AppClipCodeGenerator generate --url https://appclip.example.com --index 9 --output ~/path/to/filename.svg ``` -------------------------------- ### Passing data to the App Clip Source: https://developer.apple.com/documentation/appclip/apactivationpayload Retrieves the URL of the link that launched the App Clip. ```APIDOC ## url ### Description The URL of the link that launched the App Clip. ### Property `var url: URL?` ``` -------------------------------- ### Generate App Clip Code Without Logo Source: https://developer.apple.com/documentation/appclip/creating-app-clip-codes-with-the-app-clip-code-generator Create an App Clip Code without the App Clip logo by using the `--logo none` option. Ensure you provide the invocation URL, color index, and output file path. ```bash % AppClipCodeGenerator generate --url https://appclip.example.com --index 9 --logo none --output ~/path/to/filename.svg ``` -------------------------------- ### Understanding errors Source: https://developer.apple.com/documentation/appclip/apactivationpayload Provides information about errors related to the App Clip activation payload, including the error domain and specific error codes. ```APIDOC ## APActivationPayloadErrorDomain ### Description A string that identifies the activation payload’s error domain. ### Property `let APActivationPayloadErrorDomain: String` ``` ```APIDOC ## APActivationPayloadError ### Description An error that an App Clip activation payload returns. ### Structure `struct APActivationPayloadError` ``` ```APIDOC ## Code ### Description Error codes that an App Clip activation payload returns. ### Enum `enum Code` ``` -------------------------------- ### Define a Test App Clip Code URL Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar Provides a fallback URL in case the App Clip Code fails to decode. This is useful for testing and development. ```swift var testAppClipCodeURL = URL(string: "https://developer.apple.com/sunfl")! ``` -------------------------------- ### APActivationPayloadError.Code.doesNotMatch Case Source: https://developer.apple.com/documentation/appclip/apactivationpayloaderror/code/disallowed Use this case when the provided URL does not match the registered App Clip URL. This is an alternative error type within APActivationPayloadError.Code. ```swift case doesNotMatch ``` -------------------------------- ### APActivationPayloadError.Code.doesNotMatch Property Source: https://developer.apple.com/documentation/appclip/apactivationpayloaderror/disallowed Represents the error code when the provided URL does not match the registered invocation URL for the App Clip. This is part of interpreting errors. ```swift static var doesNotMatch: APActivationPayloadError.Code ``` -------------------------------- ### APActivationPayloadError.Code Initializer Source: https://developer.apple.com/documentation/appclip/apactivationpayloaderror/code/init%28rawvalue%3A%29 Initializes the APActivationPayloadError.Code with a raw integer value. Available on iOS 14.0+, iPadOS 14.0+, and Mac Catalyst 14.0+. ```APIDOC ## init(rawValue:) ### Description Initializes a new instance of the enumeration with the specified raw value. ### Method `init?(rawValue: Int)` ### Parameters #### Path Parameters - **rawValue** (Int) - Required - The raw integer value to associate with the enumeration case. ### Response #### Success Response (200) An instance of `APActivationPayloadError.Code` if the raw value is valid, otherwise `nil`. ### Availability - iOS 14.0+ - iPadOS 14.0+ - Mac Catalyst 14.0+ ``` -------------------------------- ### Configure AASA file for App Clips Source: https://developer.apple.com/documentation/appclip/associating-your-app-clip-with-your-website Add the appclips key to your existing AASA file to authorize your App Clip. The apps array must contain the full app identifier of your App Clip. ```json { "appclips": { "apps": ["ABCDE12345.com.example.MyApp.Clip"] } ... } ``` -------------------------------- ### confirmAcquired(in:) async Source: https://developer.apple.com/documentation/appclip/apactivationpayload/confirmacquired%28in%3Acompletionhandler%3A%29 Checks whether an App Clip invocation happened at an expected physical location using asynchronous Swift. ```APIDOC ## confirmAcquired(in:) ### Description Checks whether an App Clip invocation happened at an expected physical location asynchronously. ### Method async throws ### Endpoint N/A (Instance Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **Bool** - Indicates whether the App Clip invocation happened at the expected physical location. #### Response Example None ``` -------------------------------- ### Extract components from an invocation URL Source: https://developer.apple.com/documentation/appclip/responding-to-invocations Use this function to validate the activity type and extract the webpage URL components upon launch. ```swift func respondTo(_ activity: NSUserActivity?) { // Guard against faulty data. guard let activity, activity.activityType == NSUserActivityTypeBrowsingWeb else { return } let incomingURL = activity.webpageURL guard let components = NSURLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else { return } // Update the user interface based on URL components passed to the App Clip or full app. } ``` -------------------------------- ### confirmAcquired(in:completionHandler:) Source: https://developer.apple.com/documentation/appclip/apactivationpayload/confirmacquired%28in%3Acompletionhandler%3A%29 Checks whether an App Clip invocation happened at an expected physical location using a completion handler. ```APIDOC ## confirmAcquired(in:completionHandler:) ### Description Checks whether an App Clip invocation happened at an expected physical location. ### Method func ### Endpoint N/A (Instance Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **Bool** - Indicates whether the App Clip invocation happened at the expected physical location. - **Error?** - The error object describing why the platform couldn’t confirm the user’s physical location, or nil if successful. #### Response Example None (handled by completion handler) ``` -------------------------------- ### CSV File Format for App Clip Codes Source: https://developer.apple.com/documentation/appclip/creating-app-clip-codes-with-the-app-clip-code-generator This CSV file defines the parameters for generating App Clip Codes. Ensure the field names remain unchanged for the script to function correctly. It includes details like filename, URL, colors, and logo type. ```csv SVG File Name,URL,Background Color,Foreground Color,Type,Logo camera_standalone.svg,https://appclip.example.com,FFFFFF,000000,cam,none nfc_standalone.svg,https://appclip.example.com,FFFFFF,000000,nfc,none camera_badge.svg,https://appclip.example.com,FFFFFF,000000,cam,badge nfc_badge.svg,https://appclip.example.com,FFFFFF,000000,nfc,badge ``` -------------------------------- ### Accessing the doesNotMatch error code Source: https://developer.apple.com/documentation/appclip/apactivationpayloaderror/doesnotmatch Use this static property to identify when an App Clip invocation URL mismatch occurs. ```Swift static var doesNotMatch: APActivationPayloadError.Code { get } ``` -------------------------------- ### Define App Clip Code mapping in CSV Source: https://developer.apple.com/documentation/appclip/preparing-multiple-app-clip-codes-for-production Format for a CSV mapping file containing SVG filenames and their corresponding invocation URLs. ```csv SVG File Name, URL AppClipCode1.svg, https://example.com AppClipCode2.svg, https://appclip.example.com/ ``` -------------------------------- ### Conditional App Clip UI and Logic Source: https://developer.apple.com/documentation/appclip/fruta-building-a-feature-rich-app-with-swiftui Uses the APPCLIP compilation condition to conditionally display an App Store overlay and trigger it based on account status. ```swift VStack(spacing: 0) { Spacer() orderStatusCard Spacer() #if EXTENDED_ALL if presentingBottomBanner { bottomBanner } #endif #if APPCLIP Text(verbatim: "App Store Overlay") .hidden() .appStoreOverlay(isPresented: $presentingAppStoreOverlay) { SKOverlay.AppClipConfiguration(position: .bottom) } #endif } .onChange(of: model.hasAccount) { _ in #if APPCLIP if model.hasAccount { presentingAppStoreOverlay = true } #endif } ``` -------------------------------- ### Initialize APActivationPayloadError.Code from raw value Source: https://developer.apple.com/documentation/appclip/apactivationpayloaderror/code/init%28rawvalue%3A%29 Creates an instance of the error code from an integer raw value. Returns nil if the value does not correspond to a known error code. ```swift init?(rawValue: Int) ``` -------------------------------- ### Generate NFC-Integrated App Clip Code Source: https://developer.apple.com/documentation/appclip/creating-app-clip-codes-with-the-app-clip-code-generator Generate an SVG file for an NFC-integrated App Clip Code by setting the `--type` option to `nfc`. Include the invocation URL, color index, and output file path. ```bash % AppClipCodeGenerator generate --url https://appclip.example.com --index 9 --output ~/path/to/filename.svg --type nfc ``` -------------------------------- ### Handle ARAppClipCodeAnchor in ARSession Source: https://developer.apple.com/documentation/appclip/interacting-with-app-clip-codes-in-ar This callback is triggered when ARKit recognizes an App Clip Code. It hides the coaching overlay and prepares for URL decoding. ```swift func session(_ session: ARSession, didAdd anchors: [ARAnchor]) { for anchor in anchors { if anchor is ARAppClipCodeAnchor { // Hide the coaching overlay since ARKit recognized an App Clip Code. appClipCodeCoachingOverlay.setCoachingViewHidden(true) ``` -------------------------------- ### Add Open Graph image meta tag Source: https://developer.apple.com/documentation/appclip/supporting-invocations-from-your-website-and-the-messages-app Include this meta tag on your webpage to provide a preview image for links shared in the Messages app. ```html ```