capacitor-plugins
capacitor-plugins copied to clipboard
@capacitor/filesystem: Allow saving to ubiquity container (icloud drive)
Feature Request
Plugin
@capacitor/filesystem
Description
The ability to save to and read from iCloud shared drive.
Platform(s)
iOS
Note: This feature would not be available on android as iCloud is specific to iOS (afaik)
Preferred Solution
We could reuse the existing Directory
type Directory.External
for iOS, which currently defaults to Directory.Documents
, to indicate preference to use a ubiquity container. To keep things simple, I suggest we do not allow configuring the specific container to use, instead relying on defaults.
This would require updating FileManager.getFileUrl()
method in iOS to fetch the directory using the command:
FileManager.default.url(forUbiquityContainerIdentifier: nil)
There would need to be an additional fork in logic at this line, to fetch the icloud directory - https://github.com/ionic-team/capacitor-plugins/blob/main/filesystem/ios/Plugin/Filesystem.swift#L168.
Ideally if iCloud is not configured or present this would fall back to using Directory.Documents
.
The down side to reusing existing Directory
type is that it is a breaking change, so any clients currently using the External
type would need to make changes to there application code.
Additionally, the plugin documentation would need to be updated to include the additional steps for enabling and configuring ubiquity containers on iOS. This includes adding iCloud app entitlements and adding some config values to the info.plist
. There are a few gotcha's here that would need to be documented.
Alternatives
Rather than reusing an existing Directory
type, we could introduce an new type. Directory.iCloudDocuments
.
This would be amazing to have, looking forward to it!
Is there any other way do this in the meantime?
I'd love to know if there is a way to do this. Seems like the filesystem plugin should handle iCloud files as plenty of apps require this feature.