Skip to content

BackgroundAssets macOS xcode14.1 b3

Manuel de la Pena edited this page Oct 14, 2022 · 3 revisions

#BackgroundAssets.framework https://github.com/xamarin/xamarin-macios/pull/16350

diff -ruN /Applications/Xcode_14.1.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BAAppExtensionInfo.h /Applications/Xcode_14.1.0-beta3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BAAppExtensionInfo.h
--- /Applications/Xcode_14.1.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BAAppExtensionInfo.h	2022-09-07 13:39:50.000000000 -0500
+++ /Applications/Xcode_14.1.0-beta3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BAAppExtensionInfo.h	2022-09-22 09:18:40.000000000 -0500
@@ -11,19 +11,22 @@
 NS_ASSUME_NONNULL_BEGIN
 
 API_AVAILABLE(macos(13.0), macCatalyst(16.0), ios(16.1)) API_UNAVAILABLE(tvos, watchos)
+NS_SWIFT_SENDABLE
 @interface BAAppExtensionInfo : NSObject <NSSecureCoding>
 
-/// @brief The application identifer that this code is being called to handle.
-@property (readonly, strong) NSString               *applicationIdentifier;
+/// @brief The number of bytes remaining that can be scheduled if the total download size is restricted.
+/// @discussion When a download is restricted, your extension can only schedule up to its `BAInitialDownloadAllowance`
+/// defined in your app's `Info.plist`. This result tells you the number of bytes remaining that can be scheduled
+/// before the application is launched. Once the application is launched, this restriction is removed.
+/// @result The result is `nil` if downloads are not restricted. It returns a valid number with the remaining available download size otherwise.
+@property (readonly, strong, nullable) NSNumber *restrictedDownloadSizeRemaining
+NS_REFINED_FOR_SWIFT;
 
-/// @brief The date the extension's periodic check was invoked.
-@property (readonly, strong, nullable) NSDate       *lastPeriodicCheckTime;
+- (instancetype)init
+NS_UNAVAILABLE;
 
-/// @brief The date the last time that appliction launched and checked in to check for downloads.
-@property (readonly, strong, nullable) NSDate       *lastApplicationLaunchTime;
-
-/// @brief The download size is currently restricted. This is most likely because the application has not been launched yet.
-@property (readonly, assign) BOOL                   downloadSizeRestricted;
++ (instancetype)new
+NS_UNAVAILABLE;
 
 @end
 
diff -ruN /Applications/Xcode_14.1.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BADownload.h /Applications/Xcode_14.1.0-beta3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BADownload.h
--- /Applications/Xcode_14.1.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BADownload.h	2022-09-07 13:39:50.000000000 -0500
+++ /Applications/Xcode_14.1.0-beta3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BADownload.h	2022-09-22 09:18:40.000000000 -0500
@@ -29,10 +29,6 @@
 @property (readonly) BADownloaderPriority priority
 API_AVAILABLE(macos(13.0), macCatalyst(16.0), ios(16.1)) API_UNAVAILABLE(tvos, watchos);
 
-/// @brief When the download is in state "BADownloadStateDownloadFailed" this will the error the download failed with.
-@property (readonly, nullable) NSError *error
-API_AVAILABLE(macos(13.0), macCatalyst(16.0), ios(16.1)) API_UNAVAILABLE(tvos, watchos);
-
 - (instancetype)init
 NS_UNAVAILABLE;
 
diff -ruN /Applications/Xcode_14.1.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BADownloadManager.h /Applications/Xcode_14.1.0-beta3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BADownloadManager.h
--- /Applications/Xcode_14.1.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BADownloadManager.h	2022-09-07 13:39:50.000000000 -0500
+++ /Applications/Xcode_14.1.0-beta3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BADownloadManager.h	2022-09-22 09:18:40.000000000 -0500
@@ -64,16 +64,17 @@
 /// @param completionHandler A block to recieve the currently scheduled downloads. The block is called on the same queue as all the other completion blocks in the class.
 - (void)fetchCurrentDownloadsWithCompletionHandler:(void(^)(NSArray<BADownload *> *downloads, NSError *_Nullable error))completionHandler
 API_AVAILABLE(macos(13.0), macCatalyst(16.0), ios(16.1)) API_UNAVAILABLE(tvos, watchos)
-NS_SWIFT_NAME(currentDownloads(completionHandler:))
+NS_SWIFT_NAME(fetchCurrentDownloads(completionHandler:))
 NS_SWIFT_ASYNC_NAME(getter:currentDownloads());
 
-/// @brief Schedules a download to be done at some point in the future.
-/// @discussion Specifies a download to schedule at a priority to be downloaded some point in the future.
+/// @brief Schedules a background download.
+/// @discussion Specifies a download to schedule at a given priority. The download will automatically
+/// start at the discretion of the system.
 /// @param download A BADownload object representing a URL to be downloaded.
-/// @param outError A NSError representing why the BADownload could not be scheduled.
-/// @return YES if @c download was scheduled. NO and @c outError set if the download could not be scheduled.
+/// @param error A NSError representing why the BADownload could not be scheduled.
+/// @return YES if @c download was scheduled. NO and @c error set if the download could not be scheduled.
 - (BOOL)scheduleDownload:(BADownload *)download
-                   error:(NSError* _Nullable __autoreleasing *)outError
+                   error:(NSError* _Nullable __autoreleasing *)error
 API_AVAILABLE(macos(13.0), macCatalyst(16.0), ios(16.1)) API_UNAVAILABLE(tvos, watchos);
 
 /// @brief Acquires exclusive access to the BADownloadManager across the app and application extension.
@@ -81,7 +82,7 @@
 /// do not perform operations at the same time. Both the extension and app must use this API to ensure exclusive access.
 /// @param performHandler A block that will be executed once exclusive control is acquired.
 /// If an error is non-nil then a problem occurred acquiring exclusive access.
-- (void)performWithExclusiveControl:(void (^)(NSError *_Nullable error))performHandler
+- (void)performWithExclusiveControl:(void (^)(BOOL acquiredLock, NSError *_Nullable error))performHandler
 API_AVAILABLE(macos(13.0), macCatalyst(16.0), ios(16.1)) API_UNAVAILABLE(tvos, watchos)
 NS_SWIFT_NAME(withExclusiveControl(_:))
 NS_SWIFT_DISABLE_ASYNC;
@@ -93,9 +94,9 @@
 /// @param performHandler A block that will be executed once exclusive control is acquired.
 /// If an error is non-nil then a problem occurred acquiring exclusive access.
 - (void)performWithExclusiveControlBeforeDate:(NSDate *)date
-                                   completion:(void (^)(BOOL acquiredLock, NSError *_Nullable error))performHandler
+                               performHandler:(void (^)(BOOL acquiredLock, NSError *_Nullable error))performHandler
 API_AVAILABLE(macos(13.0), macCatalyst(16.0), ios(16.1)) API_UNAVAILABLE(tvos, watchos)
-NS_SWIFT_NAME(withExclusiveControl(beforeDate:_:))
+NS_SWIFT_NAME(withExclusiveControl(beforeDate:perform:))
 NS_SWIFT_DISABLE_ASYNC;
 
 /// @brief Attempts to schedule a BADownload in foreground mode.
@@ -105,7 +106,7 @@
 /// BAErrorDomain : BAErrorCodeCallFromExtensionNotAllowed. If this API is called from a app while it is in the background, NO will be returned along with a NSError
 /// with the settings BAErrorDomain : BAErrorCodeCallFromInactiveProcessNotAllowed.
 - (BOOL)startForegroundDownload:(BADownload *)download
-                          error:(NSError* _Nullable __autoreleasing *)outError
+                          error:(NSError* _Nullable __autoreleasing *)error
 API_AVAILABLE(macos(13.0), macCatalyst(16.0), ios(16.1)) API_UNAVAILABLE(tvos, watchos);
 
 /// @brief Cancels a download.
diff -ruN /Applications/Xcode_14.1.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BADownloaderExtension.h /Applications/Xcode_14.1.0-beta3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BADownloaderExtension.h
--- /Applications/Xcode_14.1.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BADownloaderExtension.h	2022-09-07 13:39:50.000000000 -0500
+++ /Applications/Xcode_14.1.0-beta3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BADownloaderExtension.h	2022-09-22 09:18:40.000000000 -0500
@@ -17,36 +17,47 @@
 
 @optional
 
-/// @brief This method is invoked when a containing application was installled.
-- (void)applicationDidInstallWithMetadata:(BAAppExtensionInfo *)metadata
-NS_SWIFT_NAME(applicationDidInstall(metadata:));
-
-/// @brief This method is invoked when the containing application has been updated.
-- (void)applicationDidUpdateWithMetadata:(BAAppExtensionInfo *)metadata
-NS_SWIFT_NAME(applicationDidUpdate(metadata:));
-
-/// @brief This method is invoked when the extension is notified that it should check for available updates.
-- (void)checkForUpdatesWithMetadata:(BAAppExtensionInfo *)metadata
-NS_SWIFT_NAME(checkForUpdates(metadata:));
+/*!
+ @abstract Invoked by the system when the extension should check for updated content.
+ @discussion This method will be invoked by the system upon requested events defined in `BAContentRequest`.
+ This method should return a set of all `BAURLDownload`'s that your extension would like to schedule.
+ During the invocation of this method, `BADownloadManager` will prohibit the ability to schedule additional downloads
+ until this method exits scope. Therefore, all downloads needing to be scheduled should be returned here.
+ If a download fails, it can be rescheduled using `BADownloadManager` in any other method in this protocol.
+ @param contentRequest The content request event that occured that caused this method to be invoked.
+ @param manifestURL A file URL to the local manifest that was pre-downloaded and specified in your App's Info.plist under the `BAManifestURL`.
+ The file is read-only and will be deleted after this method returns. If you wish to keep it, you must copy it out.
+ @param extensionInfo Information about your extension that may be useful for making a decision about
+ what content needs to be scheduled.
+ @result A set of unique `BAURLDownload` objects that the extension should schedule for download.
+ @warning You cannot use `BADownloadManager` to manually schedule downloads using this method. All downloads to enqueue must be returned.
+ */
+- (NSSet<BADownload *> *)downloadsForRequest:(BAContentRequest)contentRequest
+                                 manifestURL:(NSURL *)manifestURL
+                               extensionInfo:(BAAppExtensionInfo *)extensionInfo;
 
 /// @brief Download is about to begin but requires an authentication challenge to continue.
-- (void)receivedAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
-                               download:(BADownload *)download
-                      completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler;
-
-/// @brief This method is called when a download has failed but there is no `BADownloadManager` delegate to handle the completion event.
-/// @param failedDownload The download object that has failed.
-- (void)backgroundDownloadDidFail:(BADownload *)failedDownload;
+- (void)backgroundDownload:(BADownload *)download
+       didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
+         completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler;
+
+/// @abstract This method is called when a download has failed but there is no `BADownloadManager` delegate to handle the completion event.
+/// @discussion When a download has failed, this method will be invoked.
+/// If a download fails you may reschedule it with `BADownloadManager`.
+/// @param download The download object that has failed.
+/// @param error The error that caused the failure.
+- (void)backgroundDownload:(BADownload *)download failedWithError:(NSError *)error;
 
 /// @brief This method is called when a download has finished but there is no `BADownloadManager` delegate to handle the completion event.
-/// @param finishedDownload Download that has completed successfully.
+/// @param download Download that has completed successfully.
 /// @param fileURL A location to the file that has been downloaded. If the file is not moved from this location, then it may be purged by the operating system if the device becomes low on space.
-- (void)backgroundDownloadDidFinish:(BADownload *)finishedDownload
-                            fileURL:(NSURL *)fileURL;
+- (void)backgroundDownload:(BADownload *)download finishedWithFileURL:(NSURL *)fileURL;
 
 /// @brief This method may be called shortly before the extension is terminated.
 /// @discussion This method is invoked if all extension callbacks have returned or if the extension has run over it's alotted runtime.
 /// This callback provides a last chance to tidy up state before process termination.
+/// @warning This method is advisory only, there will be instances where the extension is terminated before this method is invoked.
+/// Do not rely on this method being invoked before the extension is terminated.
 - (void)extensionWillTerminate;
 
 @end
diff -ruN /Applications/Xcode_14.1.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BATypes.h /Applications/Xcode_14.1.0-beta3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BATypes.h
--- /Applications/Xcode_14.1.0-beta2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BATypes.h	2022-09-07 13:39:50.000000000 -0500
+++ /Applications/Xcode_14.1.0-beta3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BackgroundAssets.framework/Headers/BATypes.h	2022-09-22 09:18:40.000000000 -0500
@@ -20,10 +20,9 @@
     BADownloadStateFinished,
 };
 
-
 /// @brief A downloads priority
-/// @discussion A priority to which the a given download or group of downloads. This is range from NSIntegerMin to NSIntegerMax. The priority only applies to how downloads are ordered for your
-/// application. Higher priority items will be enqued for download before lower priority items regardless of order in which they are scheduled.
+/// @discussion A priority to which the a given download or group of downloads. This is a range from `BADownloaderPriorityMin` to `BADownloaderPriorityMax`.
+/// The priority only applies to how downloads are ordered for your application. Higher priority items will be enqued for download before lower priority items regardless of order in which they are scheduled.
 typedef NSInteger BADownloaderPriority NS_TYPED_EXTENSIBLE_ENUM;
 
 /// @brief A value that represents the lowest priority for a download.
@@ -38,4 +37,14 @@
 FOUNDATION_EXPORT const BADownloaderPriority BADownloaderPriorityMax
 API_AVAILABLE(macos(13.0), macCatalyst(16.0), ios(16.1)) API_UNAVAILABLE(tvos, watchos);
 
+/// @abstract The content request type used in the BADownloaderExtension.
+/// @constant BAContentRequestInstall  Content is being requested because the application was installed.
+/// @constant BAContentRequestUpdate Content is being requested because the application was updated.
+/// @constant BAContentRequestPeriodic Content is being requested because the system is asking for updated content for your application.
+typedef NS_ENUM(NSInteger, BAContentRequest) {
+    BAContentRequestInstall = 1,
+    BAContentRequestUpdate,
+    BAContentRequestPeriodic,
+};
+
 NS_ASSUME_NONNULL_END
Clone this wiki locally