ionic-team / ionic-team/capacitor-filesystem
@capacitor/filesystem: Allow saving to ubiquity container (icloud drive)
- Dominant language
- TypeScript
- Stars
- 6
- Forks
- 15
- Avg merge
- 14m
- Merged PRs (30d)
- 1
Description
## 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:
```swift
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`.
Contributor guide
Assessment
This issue has not been assessed yet.