216 Managing Documents in Your Ios Apps PDF
216 Managing Documents in Your Ios Apps PDF
216 Managing Documents in Your Ios Apps PDF
Session 216
What’s new?
•
Files app
Document Management on iOS
Client API
Sign In
Email or username
Password
Sign In
Your Drive Cancel
Sign In
Email or username
Password
Sign In
Cancel
Your Drive
Sign In
Document Management on iOS
File Provider adoption
What’s New?
Document Management on iOS NEW
File Provider–Validation tool
https://developer.apple.com/download/more/
Document Management on iOS NEW
File Provider–Validation tool
Download includes
• Source files to add to your project to enable testing
Your Drive
Your Drive
Document Management on iOS NEW
File Provider–Siri Shortcuts
Main UI is a UIDocumentBrowserViewController
Document Management on iOS NEW
Particles sample app
Main UI is a UIDocumentBrowserViewController
Main UI is a UIDocumentBrowserViewController
Main UI is a UIDocumentBrowserViewController
Main UI is a UIDocumentBrowserViewController
Available at https://developer.apple.com/download/more/
•
Document types
Interacting with Documents
What does it mean?
Interacting with Documents
What does it mean?
Your app
Interacting with Documents
What does it mean?
Cloud services
Interacting with Documents
What does it mean?
Full screen
UIDocumentBrowserViewController
Full screen
Full screen
Full screen
Can be customized
UIDocumentBrowserViewController
Full screen
Can be customized
• With your own buttons
UIDocumentBrowserViewController
Full screen
Can be customized
• With your own buttons
Full screen
Can be customized
• With your own buttons
Your container
UIDocumentPickerViewController
Your container
Your container
Your container
Your container
Get the selected file URL
override func documentPicker(_ controller: UIDocumentPickerViewController,
didPickDocumentsAt urls: [URL]) {
// use the retrieved URLs
}
Example—Access a Video from the Cloud
Get the selected file URL
override func documentPicker(_ controller: UIDocumentPickerViewController,
didPickDocumentsAt urls: [URL]) {
// use the retrieved URLs
}
Example—Access a Video from the Cloud
Get the selected file URL
override func documentPicker(_ controller: UIDocumentPickerViewController,
didPickDocumentsAt urls: [URL]) {
// use the retrieved URLs
}
Example—Access a Video from the Cloud
Get the selected file URL
override func documentPicker(_ controller: UIDocumentPickerViewController,
didPickDocumentsAt urls: [URL]) {
// use the retrieved URLs
}
Example—Access a Video from the Cloud
Get the selected file URL
override func documentPicker(_ controller: UIDocumentPickerViewController,
didPickDocumentsAt urls: [URL]) {
// use the retrieved URLs
}
•
Demo
Document Types
Document Types let the system know which files your application handles
Document Types
Document Types
Two steps—
• Declaring the type if it is not already declared by iOS
Standard
file type
Declaring a Type
Standard
file type
Already declared
by iOS?
Declaring a Type
Standard
file type
Already declared
by iOS?
https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/UTIRef/Articles/System-
DeclaredUniformTypeIdentifiers.html
Declaring a Type
Standard
file type
Already declared
by iOS?
Yes
Nothing to do
https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/UTIRef/Articles/System-
DeclaredUniformTypeIdentifiers.html
Declaring a Type
Standard
file type
Yes
https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/UTIRef/Articles/System-
DeclaredUniformTypeIdentifiers.html
Declaring a New File Type
Info.plist
An identifier
(UTTypeIdentifier)
Declaring a New File Type
An identifier
(UTTypeIdentifier)
Declaring a New File Type
public.jpeg
Type Conformance
public.jpeg public.heif-standard
Type Conformance
public.image
public.jpeg public.heif-standard
Type Conformance
public.content
public.image
public.jpeg public.heif-standard
Type Conformance
public.content
public.spreadsheet public.image
public.jpeg public.heif-standard
Type Conformance
public.content
public.jpeg public.heif-standard
Type Conformance
public.content
public.jpeg public.heif-standard
Type Conformance
public.content
…particles
Type Conformance
public.data
public.content
Single file on disk
…particles
Type Conformance
public.data com.apple.package
public.content
Single file on disk File package
…particles
Type Conformance
public.data com.apple.package
public.content
Single file on disk File package
…particles
Type Conformance
public.item
Root type
public.data com.apple.package
public.content
Single file on disk File package
…particles
Declaring a New File Type
Standard
file type
Yes
Standard
file type
Yes
Standard
file type
Yes
Standard
file type
Yes
Standard
file type
Yes No
Once the type is defined, you need to claim support for it in Info.plist
Claiming Support for a Type
Three choices
Claiming Support for a Type—Handler Rank
Three choices
Three choices
Three choices
Three choices
Be as specific as possible
// MARK: UIDocumentBrowserViewControllerDelegate
func documentBrowser(_ controller: UIDocumentBrowserViewController,
didPickDocumentURLs documentURLs: [URL])
// MARK: UIDocumentPickerDelegate
func documentPicker(_ controller: UIDocumentPickerViewController,
didPickDocumentsAt urls: [URL])
Your App and the Sandbox
// MARK: UIDocumentBrowserViewControllerDelegate
func documentBrowser(_ controller: UIDocumentBrowserViewController,
didPickDocumentURLs documentURLs: [URL])
// MARK: UIDocumentPickerDelegate
func documentPicker(_ controller: UIDocumentPickerViewController,
didPickDocumentsAt urls: [URL])
Your App and the Sandbox
// MARK: UIDocumentBrowserViewControllerDelegate
func documentBrowser(_ controller: UIDocumentBrowserViewController,
didPickDocumentURLs documentURLs: [URL])
// MARK: UIDocumentPickerDelegate
func documentPicker(_ controller: UIDocumentPickerViewController,
didPickDocumentsAt urls: [URL])
Your App and the Sandbox
Document Picker
URL
Your App
Your App and the Sandbox
URL
Your App
Your App and the Sandbox
URL
Your App
Your App
Other App
App
Container
Cloud Service
Your App and the Sandbox
App Container
Your App
Other App
Unrestricted
Cloud Service Container
access
App
Container
Cloud Service
Your App and the Sandbox
App Container
Your App
Restricted
access
Other App
Unrestricted
Cloud Service Container
access
App
Container
Cloud Service
Your App and the Sandbox
Your App
App Container
Restricted
Unrestricted access
access
App
Container Other App
Your App and the Sandbox
URL
Your App
App Container
Restricted
Unrestricted access
access
App
Container Other App
Your App and the Sandbox
Security
URL URLscoped
Your App resource
App Container
Restricted
Unrestricted access
access
App
Container Other App
Your App and the Sandbox
Security
URL URLscoped
Your App resource
App Container
Restricted
Unrestricted access
access
App
Container Other App
func stopAccessingSecurityScopedResource()
Your App and the Sandbox
Security
URL URLscoped
Your App resource
App Container
Access
Unrestricted granted
access
App
Container Other App
func stopAccessingSecurityScopedResource()
Your App and the Sandbox
Security
URL URLscoped
Your App resource
App Container
Restricted
Unrestricted access
access
App
Container Other App
func stopAccessingSecurityScopedResource()
Your App and the Sandbox
Your App and the Sandbox
let didStartAccessing = url.startAccessingSecurityScopedResource()
defer {
if didStartAccessing {
url.stopAccessingSecurityScopedResource()
}
}
// do something with URL
Your App and the Sandbox
let didStartAccessing = url.startAccessingSecurityScopedResource()
defer {
if didStartAccessing {
url.stopAccessingSecurityScopedResource()
}
}
// do something with URL
Your App and the Sandbox
let didStartAccessing = url.startAccessingSecurityScopedResource()
defer {
if didStartAccessing {
url.stopAccessingSecurityScopedResource()
}
}
// do something with URL
Your App and the Sandbox
let didStartAccessing = url.startAccessingSecurityScopedResource()
defer {
if didStartAccessing {
url.stopAccessingSecurityScopedResource()
}
}
// do something with URL
Cloud Service
Coordinating File Access
Cloud Service
Coordinating File Access
Cloud Service
Coordinating File Access
Coordinating File Access
Foreground
Your App
Foreground Background
Your App
Relaunched
Your App
Memory Pressure
Relaunched
Cloud Service
State Restoration
How do we implement it?
Cloud Service
State Restoration
How do we implement it?
Cloud Service
State Restoration
How do we implement it?
Cloud Service
Cloud Service
Cloud Service
State Restoration
How do we implement it?
Cloud Service
State Restoration
How do we implement it?
Demo
Copy to
Copy to
Open in place
Open in place
Open In Place
Adoption
Open In Place
Adoption
Support cancellation
Open In Place
Progress reporting
Open In Place
Progress reporting
Adopt UIDocument
Raising the Bar
Adopt UIDocument
Adopt UIDocument
Adopt UIDocument
Adopt UIDocument
• Siri Shortcuts
Summary
• Siri Shortcuts