@capgo/capacitor-file-sharer 8.1.11 → 8.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # @capgo/capacitor-file-sharer
2
2
 
3
- Share files through the native share sheet or save them to the device from your Capacitor app. On web, the same calls download the file.
3
+ Share files through the native share sheet from your Capacitor app, or save them to the device on Android. On web, the same calls download the file.
4
4
 
5
5
  <a href="https://capgo.app/?ref=plugin_file_sharer"><img src="https://capgo.app/readme-banner.svg?repo=Cap-go/capacitor-file-sharer" alt="Capgo - Instant updates for Capacitor" /></a>
6
6
 
7
7
  <div align="center">
8
- <p><b>Capgo</b>: open-source live updates for Ionic and Capacitor apps. Ship OTA fixes and features instantly, without waiting for app store review.</p>
8
+ <p><b>Capgo</b>: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.</p>
9
9
  <h2><a href="https://capgo.app/register/?ref=plugin_file_sharer">➡️ Get started for free</a></h2>
10
10
  <p>14-day unlimited free trial. No credit card required</p>
11
11
  <p><a href="https://capgo.app/consulting/?ref=plugin_file_sharer">Missing a feature? We'll build the plugin for you 💪</a></p>
@@ -18,7 +18,7 @@ Share files through the native share sheet or save them to the device from your
18
18
  ## Key features
19
19
 
20
20
  - **Share**: `share()` opens the native share sheet on iOS and Android.
21
- - **Save**: `save()` stores a file locally, using MediaStore on Android.
21
+ - **Save**: on Android, `save()` stores the file with MediaStore where supported and a legacy path on older versions. On iOS it opens the share sheet so the user picks the destination.
22
22
  - **Flexible input**: pass base64 data or a local file.
23
23
  - **Web fallback**: both methods download the file in the browser.
24
24
  - **Platforms**: iOS, Android and Web.
@@ -47,15 +47,17 @@ public class FileSharerPlugin: CAPPlugin, CAPBridgedPlugin {
47
47
  return
48
48
  }
49
49
 
50
- var activityItems: [Any] = [fileUrl]
50
+ var activityItems: [Any] = []
51
+ if let subject = call.getString("subject") ?? call.getString("title") {
52
+ activityItems.append(FileShareActivityItemSource(fileURL: fileUrl, subject: subject))
53
+ } else {
54
+ activityItems.append(fileUrl)
55
+ }
51
56
  if let text = call.getString("text"), !text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
52
57
  activityItems.append(text)
53
58
  }
54
59
 
55
60
  let activityViewController = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
56
- if let subject = call.getString("subject") ?? call.getString("title") {
57
- activityViewController.setValue(subject, forKey: "subject")
58
- }
59
61
 
60
62
  if let sourceView = viewController.view {
61
63
  activityViewController.popoverPresentationController?.sourceView = sourceView
@@ -128,6 +130,34 @@ public class FileSharerPlugin: CAPPlugin, CAPBridgedPlugin {
128
130
  }
129
131
  }
130
132
 
133
+ private final class FileShareActivityItemSource: NSObject, UIActivityItemSource {
134
+ private let fileURL: URL
135
+ private let subject: String
136
+
137
+ init(fileURL: URL, subject: String) {
138
+ self.fileURL = fileURL
139
+ self.subject = subject
140
+ }
141
+
142
+ func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any {
143
+ fileURL
144
+ }
145
+
146
+ func activityViewController(
147
+ _ activityViewController: UIActivityViewController,
148
+ itemForActivityType activityType: UIActivity.ActivityType?
149
+ ) -> Any? {
150
+ fileURL
151
+ }
152
+
153
+ func activityViewController(
154
+ _ activityViewController: UIActivityViewController,
155
+ subjectForActivityType activityType: UIActivity.ActivityType?
156
+ ) -> String {
157
+ subject
158
+ }
159
+ }
160
+
131
161
  private enum FileSharerError: String, Error {
132
162
  case noFilename = "ERR_PARAM_NO_FILENAME"
133
163
  case noData = "ERR_PARAM_NO_DATA"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-file-sharer",
3
- "version": "8.1.11",
3
+ "version": "8.1.13",
4
4
  "description": "Capacitor plugin for sharing and saving files on Android, iOS, and Web.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",