@capacitor/share 4.0.0-beta.2 → 4.0.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.0.0](https://github.com/ionic-team/capacitor-plugins/compare/4.0.0-beta.2...4.0.0) (2022-07-27)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **share:** Prevent crash on no shareable files ([#1088](https://github.com/ionic-team/capacitor-plugins/issues/1088)) ([dc67e7b](https://github.com/ionic-team/capacitor-plugins/commit/dc67e7b96daa99e2d020b76005e37d93b610bbf2))
12
+
13
+
14
+
15
+
16
+
6
17
  # [4.0.0-beta.2](https://github.com/ionic-team/capacitor-plugins/compare/4.0.0-beta.0...4.0.0-beta.2) (2022-07-08)
7
18
 
8
19
  **Note:** Version bump only for package @capacitor/share
package/README.md CHANGED
@@ -11,6 +11,9 @@ API](https://web.dev/web-share/)), though web support is currently spotty.
11
11
  npm install @capacitor/share
12
12
  npx cap sync
13
13
  ```
14
+ ## Android
15
+
16
+ By default, Capacitor apps only allow to share files from caches folder. To make other Android folders shareable, they have to be added in `android/app/src/main/res/xml/file_paths.xml` file. Check the Specifying Available Files section in [FileProvider docs](https://developer.android.com/reference/androidx/core/content/FileProvider) for the available locations.
14
17
 
15
18
  ## Example
16
19
 
@@ -91,15 +91,21 @@ public class SharePlugin extends Plugin {
91
91
  type = "*/*";
92
92
  }
93
93
  intent.setType(type);
94
- Uri fileUrl = FileProvider.getUriForFile(
95
- getActivity(),
96
- getContext().getPackageName() + ".fileprovider",
97
- new File(Uri.parse(url).getPath())
98
- );
99
- intent.putExtra(Intent.EXTRA_STREAM, fileUrl);
100
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
101
- intent.setDataAndType(fileUrl, type);
94
+ try {
95
+ Uri fileUrl = FileProvider.getUriForFile(
96
+ getActivity(),
97
+ getContext().getPackageName() + ".fileprovider",
98
+ new File(Uri.parse(url).getPath())
99
+ );
100
+ intent.putExtra(Intent.EXTRA_STREAM, fileUrl);
101
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
102
+ intent.setDataAndType(fileUrl, type);
103
+ }
104
+ } catch (Exception ex) {
105
+ call.reject(ex.getLocalizedMessage());
106
+ return;
102
107
  }
108
+
103
109
  intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
104
110
  }
105
111
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/share",
3
- "version": "4.0.0-beta.2",
3
+ "version": "4.0.0",
4
4
  "description": "The Share API provides methods for sharing content in any sharing-enabled apps the user may have installed.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "32240b675c12a774920c07a86b4483ecec7a9c8d"
82
+ "gitHead": "27bd016fc57850ae151ae06017bb1e9ee0d62975"
83
83
  }