-
Bring desktop class sync to iOS with FileProvider
Discover how you can sync files faster and more efficiently within your iPhone and iPad apps when you create a File Provider extension. Sync up with the File Provider team and learn how to build a modern File Provider for iOS. We'll show you how to architect your app to support seamless file sync, uploads, and downloads. And we'll explore how you can go stateless and fortify your file provider against unexpected conditions.
To get the most out of this session, we recommend having experience with File Providers on macOS.Recursos
- Synchronizing files using file provider extensions
- Sending notification requests to APNs
- File Provider UI
- File Provider
Vídeos relacionados
WWDC21
-
Buscar neste vídeo...
-
-
6:04 - Implement a Progress Cancellation Handler
// Implementing a progress cancellation handler public func modifyItem(_ item: ..., completionHandler: (..., Error?) -> Void) -> Progress { let progress = Progress() let uploadTask = Task { do { // ... try Task.checkCancellation() // ... } catch let error { completionHandler(nil, [], false, error) } } progress.cancellationHandler = { uploadTask.cancel() } return progress } -
6:53 - Register for Push Notifications
// Registering for push notifications import PushKit let pushRegistry = PKPushRegistry(queue: queue) pushRegistry.delegate = self pushRegistry.desiredPushTypes = Set([PKPushType.fileProvider]) ... // On the server: push // // { // "container-identifier" = "NSFileProviderWorkingSetContainerItemIdentifier" // "domain" = "<domain identifier>" // } // // with topic "<your application identifier>.pushkit.fileprovider" -
8:53 - Drag and Drop: Implement Dragging
// Sending out drags var body: some View { Text("🥐") .onDrag { let itemProvider = NSItemProvider() itemProvider.registerFileRepresentation(for: .folder, openInPlace: true) { completionHandler in self.manager.getUserVisibleURL(for: folderItemID) { fileURL, error in guard let fileURL = fileURL else { completionHandler(nil, false, error) return } completionHandler(fileURL, true, nil) } return Progress() } return itemProvider } } -
9:24 - Drag and Drop: Implement Dropping
// Receiving drops var body: some View { Text("🥬") .onDrop(of: [.folder], isTargeted: $dropTarget) { providers in guard let prov = providers.first(where: { provider in !provider.registeredContentTypes(conformingTo: .folder).isEmpty }) else { return false } prov.loadFileRepresentation(for: .folder, openInPlace: true) { url, inPlace, err in guard let url = url else { return } Task { url.startAccessingSecurityScopedResource() // use URL url.stopAccessingSecurityScopedResource() } } return true } }
-