objc2-background-assets 0.3.2

Bindings to the BackgroundAssets framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

extern_protocol!(
    /// An application extension that uses the system implementation to schedule asset-pack downloads automatically.
    ///
    /// The protocol provides default implementations for all of the inherited ``BADownloaderExtension-zuvm`` requirements.
    /// - Warning: Don’t implement any of the inherited ``BADownloaderExtension-zuvm`` requirements aside from, optionally, ``BADownloaderExtension-zuvm/backgroundDownload:didReceiveChallenge:completionHandler:``.
    ///
    /// ## Creating an Objective-C Downloader Extension
    /// Xcode’s Background Download extension template generates Swift code when you select either the “Apple-Hosted, Managed” option or the “Self-Hosted, Managed” option, but you can easily switch to Objective-C instead if you prefer. To do so, follow these steps:
    /// 1. Remove `BackgroundDownloadHandler.swift`.
    /// 2. Create `DownloaderExtension.h` with the following contents:
    /// ### Apple Hosting
    /// ```objc
    /// #import
    /// <StoreKit
    /// /StoreKit.h>
    ///
    /// @
    /// interface DownloaderExtension : NSObject
    /// <SKDownloaderExtension
    /// >
    ///
    /// ```
    ///
    /// ### Self Hosting
    /// ```objc
    /// #import
    /// <BackgroundAssets
    /// /BackgroundAssets.h>
    ///
    /// @
    /// interface DownloaderExtension : NSObject
    /// <BAManagedDownloaderExtension
    /// >
    ///
    /// ```
    ///
    /// (Remove any backslash characters that may be rendered in the above code snippets.)
    ///
    /// 3. Create `DownloaderExtension.m` with the following contents:
    /// ```objc
    /// #import "DownloaderExtension.h"
    ///
    /// DownloaderExtension
    ///
    /// - (BOOL)shouldDownloadAssetPack:(BAAssetPack *)assetPack {
    /// // Use this method to filter out asset packs that the system would otherwise download automatically. You can also remove this method entirely if you just want to rely on the default download behavior.
    /// return true;
    /// }
    ///
    /// ```
    /// 4. Add `DownloaderExtension.m` to your extension’s target.
    /// 5. Add the following snippet inside your extension’s `Info.plist`’s `EXAppExtensionAttributes` dictionary:
    /// ```plist
    /// <key
    /// >EXPrincipalClass
    /// </key
    /// >
    /// <string
    /// >DownloaderExtension
    /// </string
    /// >
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/backgroundassets/bamanageddownloaderextension?language=objc)
    #[cfg(feature = "BADownloaderExtension")]
    pub unsafe trait BAManagedDownloaderExtension: BADownloaderExtension {
        #[cfg(feature = "BAAssetPack")]
        /// Determines whether to download an asset pack.
        ///
        /// By default, the system automatically downloads all applicable asset packs with either “essential” or “prefetch” download policies for the current installation event type. You can optionally implement this method to filter out unwanted asset packs at runtime.
        /// - Parameter assetPack: An asset pack that’s being considered as a candidate to be downloaded.
        /// - Returns: Whether the asset pack should be downloaded.
        #[optional]
        #[unsafe(method(shouldDownloadAssetPack:))]
        #[unsafe(method_family = none)]
        unsafe fn shouldDownloadAssetPack(&self, asset_pack: &BAAssetPack) -> bool;
    }
);