com-easystep2-datawedge-plugin-intent-cordova 4.2.3 → 4.3.2

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
@@ -3,23 +3,21 @@
3
3
 
4
4
  # EasyStep2 DataWedge Plugin Intent
5
5
 
6
- This is an updated and maintained version of the original [darryncampbell-cordova-plugin-intent](https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent) plugin, now named `com.easystep2.datawedge.plugin.intent`.
6
+ This is an updated and maintained version of the original [darryncampbell-cordova-plugin-intent](https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent) plugin, now named `com.easystep2.datawedge.plugin.intent-cordova`.
7
7
 
8
- [![npm version](http://img.shields.io/npm/v/com.easystep2.datawedge.plugin.intent.svg?style=flat-square)](https://npmjs.org/package/com.easystep2.datawedge.plugin.intent "View this project on npm")
8
+ [![npm version](http://img.shields.io/npm/v/com.easystep2.datawedge.plugin.intent.svg?style=flat-square)](https://www.npmjs.com/package/com-easystep2-datawedge-plugin-intent-cordova "View this project on npm")
9
9
 
10
10
  ## Enhancements by EasyStep2
11
11
  - Fixed compatibility issues with Angular 14+
12
- - Maintained in two branches:
13
- - **cordova**: For traditional Cordova applications
14
- - **capacitor**: For Ionic Capacitor applications
12
+ - Support for both Cordova and Capacitor in a single package
15
13
  - Regularly updated and maintained
16
14
 
17
15
  The original plugin badges are preserved for reference:
18
16
 
19
- [![Original npm version](http://img.shields.io/npm/v/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square&label=original)](https://npmjs.org/package/com-darryncampbell-cordova-plugin-intent "View original project on npm")
20
- [![Original npm downloads](http://img.shields.io/npm/dm/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square&label=original%20downloads)](https://npmjs.org/package/com-darryncampbell-cordova-plugin-intent "View original project on npm")
21
- [![Original npm total downloads](http://img.shields.io/npm/dt/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square&label=original%20total)](https://npmjs.org/package/com-darryncampbell-cordova-plugin-intent "View original project on npm")
22
- [![Original npm licence](http://img.shields.io/npm/l/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square&label=license)](https://npmjs.org/package/com-darryncampbell-cordova-plugin-intent "View original project on npm")
17
+ [![Original npm version](http://img.shields.io/npm/v/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square&label=original)](https://npmjs.org/package/com-darryncampbell/darryncampbell-cordova-plugin-intent "View original project on npm")
18
+ [![Original npm downloads](http://img.shields.io/npm/dm/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square&label=original%20downloads)](https://npmjs.org/package/com-darryncampbell/darryncampbell-cordova-plugin-intent "View original project on npm")
19
+ [![Original npm total downloads](http://img.shields.io/npm/dt/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square&label=original%20total)](https://npmjs.org/package/com-darryncampbell/darryncampbell-cordova-plugin-intent "View original project on npm")
20
+ [![Original npm licence](http://img.shields.io/npm/l/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square&label=license)](https://npmjs.org/package/com-darryncampbell/darryncampbell-cordova-plugin-intent "View original project on npm")
23
21
 
24
22
  Note: the original plugin was the underlying implementation for https://www.npmjs.com/package/@ionic-native/web-intent and https://ionicframework.com/docs/native/web-intent/
25
23
 
@@ -51,15 +49,97 @@ An example application is available at https://github.com/darryncampbell/plugin-
51
49
 
52
50
  ### Cordova
53
51
  ```bash
54
- cordova plugin add com.easystep2.datawedge.plugin.intent
52
+ # Install from npm
53
+ npm install com-easystep2-datawedge-plugin-intent-cordova
54
+ cordova plugin add com-easystep2-datawedge-plugin-intent-cordova
55
+
56
+ # Or install directly from GitHub
57
+ cordova plugin add https://github.com/easystep2/easystep2-datawedge-plugin-intent.git
58
+ ```
59
+
60
+ ### Ionic Capacitor
61
+ ```bash
62
+ # Install from npm
63
+ npm install com-easystep2-datawedge-plugin-intent-capacitor
64
+
65
+ # Or install directly from GitHub
66
+ npm install https://github.com/easystep2/easystep2-datawedge-plugin-intent.git
67
+
68
+ # Then sync your project
69
+ npx cap sync
70
+ ```
71
+
72
+ ## Uninstallation
73
+
74
+ ### Cordova
75
+ ```bash
76
+ cordova plugin remove com-easystep2-datawedge-plugin-intent-cordova
77
+ npm uninstall com-easystep2-datawedge-plugin-intent-cordova
55
78
  ```
56
79
 
57
80
  ### Ionic Capacitor
58
81
  ```bash
59
- npm install com.easystep2.datawedge.plugin.intent
82
+ npm uninstall com-easystep2-datawedge-plugin-intent-capacitor
60
83
  npx cap sync
61
84
  ```
62
85
 
86
+ ## Package Architecture
87
+ This project has been restructured to support both Cordova and Capacitor applications from a single codebase, with specific npm packages for each platform.
88
+
89
+ ### Support for Multiple Platforms
90
+ The plugin provides:
91
+ - `com-easystep2-datawedge-plugin-intent-cordova` for Cordova projects
92
+ - `com-easystep2-datawedge-plugin-intent-capacitor` for Capacitor projects
93
+ - Consistent API across both platforms
94
+ - Simplified maintenance and updates
95
+
96
+ ### Migration from Previous Versions
97
+ If you were previously using a different version:
98
+
99
+ ```bash
100
+ # For Cordova projects
101
+ cordova plugin remove com.easystep2.datawedge.plugin.intent
102
+ npm uninstall com.easystep2.datawedge.plugin.intent
103
+ npm install com-easystep2-datawedge-plugin-intent-cordova
104
+ cordova plugin add com-easystep2-datawedge-plugin-intent-cordova
105
+
106
+ # For Capacitor projects
107
+ npm uninstall com.easystep2.datawedge.plugin.intent
108
+ npm install com-easystep2-datawedge-plugin-intent-capacitor
109
+ npx cap sync
110
+ ```
111
+
112
+ ## Version Bump Guidelines
113
+ When bumping versions, follow semantic versioning:
114
+ - **MAJOR**: Breaking changes
115
+ - **MINOR**: New features without breaking changes
116
+ - **PATCH**: Bug fixes without breaking changes
117
+
118
+ ## Troubleshooting
119
+
120
+ ### Common Issues
121
+ - **Intent not firing**: Verify your broadcast receiver is properly registered
122
+ - **Data not received**: Check your intent extras format and data types
123
+ - **Conflicts with other plugins**: Install this plugin after other intent-related plugins
124
+ - **Angular issues**: For Angular 14+, use version 2.x.x or later
125
+
126
+ ### DataWedge Specific Issues
127
+ If you're using this plugin with Zebra DataWedge:
128
+ - Ensure your DataWedge profile is configured correctly
129
+ - Verify the intent output is enabled
130
+ - Confirm the intent action and category match your registration
131
+
132
+ ### Platform-Specific Issues
133
+ - **Cordova**: If you experience issues with older Cordova versions, check compatibility in the plugin.xml
134
+ - **Capacitor**: For Capacitor 3+, ensure you're using plugin version 2.x.x or higher
135
+
136
+ ### Debug Mode
137
+ Enable debug mode for more verbose logging:
138
+
139
+ ```javascript
140
+ window.plugins.intentShim.setDebugMode(true);
141
+ ```
142
+
63
143
  ## Supported Platforms
64
144
  - Android
65
145
 
@@ -343,6 +423,3 @@ The following constants are defined in the plugin for use in JavaScript
343
423
  ## Tested Versions
344
424
 
345
425
  Tested with Cordova version 6.5.0 and Cordova Android version 6.2.1
346
-
347
-
348
-
@@ -0,0 +1,33 @@
1
+ const fs = require("fs");
2
+
3
+ function androidXUpgrade (ctx) {
4
+ if (!ctx.opts.platforms.includes('android'))
5
+ return;
6
+
7
+ const enableAndroidX = "android.useAndroidX=true";
8
+ const enableJetifier = "android.enableJetifier=true";
9
+ const gradlePropertiesPath = "./platforms/android/gradle.properties";
10
+
11
+ let gradleProperties = fs.readFileSync(gradlePropertiesPath, "utf8");
12
+
13
+ if (gradleProperties)
14
+ {
15
+ const isAndroidXEnabled = gradleProperties.includes(enableAndroidX);
16
+ const isJetifierEnabled = gradleProperties.includes(enableJetifier);
17
+
18
+ if (isAndroidXEnabled && isJetifierEnabled)
19
+ return;
20
+
21
+ if (isAndroidXEnabled === false)
22
+ gradleProperties += "\n" + enableAndroidX;
23
+
24
+ if (isJetifierEnabled === false)
25
+ gradleProperties += "\n" + enableJetifier;
26
+
27
+ fs.writeFileSync(gradlePropertiesPath, gradleProperties);
28
+ }
29
+ }
30
+
31
+ module.exports = function (ctx) {
32
+ androidXUpgrade(ctx);
33
+ };
package/package.json CHANGED
@@ -1,16 +1,23 @@
1
1
  {
2
2
  "name": "com-easystep2-datawedge-plugin-intent-cordova",
3
- "version": "4.2.3",
4
- "description": "Capacitor and Cordova plugins for Android Intents",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
3
+ "version": "4.3.2",
4
+ "description": "Cordova plugin for Android Intents and Zebra DataWedge",
5
+ "main": "www/IntentShim.js",
6
+ "files": [
7
+ "src/android",
8
+ "www",
9
+ "hooks",
10
+ "plugin.xml",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "author": "Easystep2",
15
+ "license": "MIT",
8
16
  "repository": {
9
17
  "type": "git",
10
18
  "url": "git+https://github.com/easystep2/easystep2-datawedge-plugin-intent.git"
11
19
  },
12
20
  "keywords": [
13
- "capacitor",
14
21
  "cordova",
15
22
  "plugin",
16
23
  "android",
@@ -18,10 +25,10 @@
18
25
  "datawedge",
19
26
  "zebra",
20
27
  "scanner",
21
- "barcode"
28
+ "barcode",
29
+ "ecosystem:cordova",
30
+ "cordova-android"
22
31
  ],
23
- "author": "Easystep2",
24
- "license": "MIT",
25
32
  "cordova": {
26
33
  "id": "com-easystep2-datawedge-plugin-intent-cordova",
27
34
  "platforms": [
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="com-easystep2-datawedge-plugin-intent" version="4.1.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <plugin version="4.3.2" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
3
3
  <name>Intent Shim</name>
4
4
  <js-module name="IntentShim" src="www/IntentShim.js">
5
5
  <clobbers target="intentShim" />
@@ -78,7 +78,4 @@
78
78
  <framework src="androidx.core:core:1.1.0" />
79
79
  </platform>
80
80
 
81
- </plugin>
82
- </platform>
83
-
84
- </plugin>
81
+ </plugin>
@@ -0,0 +1,289 @@
1
+ var argscheck = require('cordova/argscheck'),
2
+ channel = require('cordova/channel'),
3
+ utils = require('cordova/utils'),
4
+ exec = require('cordova/exec'),
5
+ cordova = require('cordova');
6
+
7
+
8
+ /**
9
+ * This represents a thin shim layer over the Android Intent implementation
10
+ * @constructor
11
+ */
12
+ function IntentShim() {
13
+ var me = this;
14
+
15
+ /**
16
+ * Check and request necessary permissions for Android 13+
17
+ *
18
+ * @param {Function} successCallback - Function to call on success
19
+ * @param {Function} errorCallback - Function to call on error
20
+ */
21
+ this.checkAndRequestPermissions = function (successCallback, errorCallback) {
22
+ if (cordova.platformId === 'android') {
23
+ cordova.exec(
24
+ successCallback,
25
+ errorCallback,
26
+ "IntentShim",
27
+ "checkAndRequestPermissions",
28
+ []
29
+ );
30
+ } else {
31
+ // Non-Android platforms don't need these specific permissions
32
+ successCallback();
33
+ }
34
+ };
35
+
36
+ /**
37
+ * Modified startActivity to handle permissions for Android 13+
38
+ */
39
+ this.startActivity = function (params, successCallback, errorCallback) {
40
+ // First check permissions, then proceed with action
41
+ this.checkAndRequestPermissions(
42
+ function () {
43
+ cordova.exec(
44
+ successCallback,
45
+ errorCallback,
46
+ "IntentShim",
47
+ "startActivity",
48
+ [params]
49
+ );
50
+ },
51
+ errorCallback
52
+ );
53
+ };
54
+
55
+ /**
56
+ * Modified startActivityForResult to handle permissions for Android 13+
57
+ */
58
+ this.startActivityForResult = function (params, successCallback, errorCallback) {
59
+ // First check permissions, then proceed with action
60
+ this.checkAndRequestPermissions(
61
+ function () {
62
+ cordova.exec(
63
+ successCallback,
64
+ errorCallback,
65
+ "IntentShim",
66
+ "startActivityForResult",
67
+ [params]
68
+ );
69
+ },
70
+ errorCallback
71
+ );
72
+ };
73
+ }
74
+
75
+ IntentShim.prototype.ACTION_SEND = "android.intent.action.SEND";
76
+ IntentShim.prototype.ACTION_VIEW = "android.intent.action.VIEW";
77
+ IntentShim.prototype.ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
78
+ IntentShim.prototype.ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
79
+ IntentShim.prototype.EXTRA_TEXT = "android.intent.extra.TEXT";
80
+ IntentShim.prototype.EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
81
+ IntentShim.prototype.EXTRA_STREAM = "android.intent.extra.STREAM";
82
+ IntentShim.prototype.EXTRA_EMAIL = "android.intent.extra.EMAIL";
83
+ IntentShim.prototype.ACTION_CALL = "android.intent.action.CALL";
84
+ IntentShim.prototype.ACTION_SENDTO = "android.intent.action.SENDTO";
85
+ // StartActivityForResult
86
+ IntentShim.prototype.ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
87
+ IntentShim.prototype.ACTION_PICK = "android.intent.action.PICK";
88
+ IntentShim.prototype.RESULT_CANCELED = 0; // Activity.RESULT_CANCELED
89
+ IntentShim.prototype.RESULT_OK = -1; // Activity.RESULT_OK
90
+
91
+ IntentShim.prototype.startActivity = function (params, successCallback, errorCallback) {
92
+ argscheck.checkArgs('off', 'IntentShim.startActivity', arguments);
93
+ exec(successCallback, errorCallback, "IntentShim", "startActivity", [params]);
94
+ };
95
+
96
+ IntentShim.prototype.startActivityForResult = function (params, successCallback, errorCallback) {
97
+ argscheck.checkArgs('off', 'IntentShim.startActivityForResult', arguments);
98
+ exec(successCallback, errorCallback, "IntentShim", "startActivityForResult", [params]);
99
+ };
100
+
101
+ IntentShim.prototype.sendBroadcast = function (params, successCallback, errorCallback) {
102
+ argscheck.checkArgs('off', 'IntentShim.sendBroadcast', arguments);
103
+ exec(successCallback, errorCallback, "IntentShim", "sendBroadcast", [params]);
104
+ };
105
+
106
+ IntentShim.prototype.startService = function (params, successCallback, errorCallback) {
107
+ argscheck.checkArgs('off', 'IntentShim.startService', arguments);
108
+ exec(successCallback, errorCallback, "IntentShim", "startService", [params]);
109
+ };
110
+
111
+ IntentShim.prototype.registerBroadcastReceiver = function (params, callback) {
112
+ argscheck.checkArgs('of', 'IntentShim.registerBroadcastReceiver', arguments);
113
+ exec(callback, null, "IntentShim", "registerBroadcastReceiver", [params]);
114
+ };
115
+
116
+ IntentShim.prototype.unregisterBroadcastReceiver = function () {
117
+ argscheck.checkArgs('', 'IntentShim.unregisterBroadcastReceiver', arguments);
118
+ exec(null, null, "IntentShim", "unregisterBroadcastReceiver", []);
119
+ };
120
+
121
+ IntentShim.prototype.onIntent = function (callback) {
122
+ argscheck.checkArgs('f', 'IntentShim.onIntent', arguments);
123
+ exec(callback, null, "IntentShim", "onIntent", [callback]);
124
+ };
125
+
126
+ IntentShim.prototype.onActivityResult = function (callback) {
127
+ argscheck.checkArgs('f', 'IntentShim.onActivityResult', arguments);
128
+ exec(callback, null, "IntentShim", "onActivityResult", [callback]);
129
+ };
130
+
131
+ IntentShim.prototype.getIntent = function (successCallback, failureCallback) {
132
+ argscheck.checkArgs('ff', 'IntentShim.getIntent', arguments);
133
+ exec(successCallback, failureCallback, "IntentShim", "getIntent", []);
134
+ };
135
+
136
+ IntentShim.prototype.sendResult = function (params, callback) {
137
+ argscheck.checkArgs('of', 'IntentShim.sendResult', arguments);
138
+ exec(callback, null, "IntentShim", "sendResult", [params]);
139
+ }
140
+
141
+ IntentShim.prototype.realPathFromUri = function (params, successCallback, errorCallback) {
142
+ argscheck.checkArgs('off', 'IntentShim.realPathFromUri', arguments);
143
+ exec(successCallback, errorCallback, "IntentShim", "realPathFromUri", [params]);
144
+ };
145
+
146
+ IntentShim.prototype.packageExists = function (packageName, successCallback) {
147
+ argscheck.checkArgs('sf', 'IntentShim.packageExists', arguments);
148
+ exec(successCallback, null, "IntentShim", "packageExists", [packageName]);
149
+ };
150
+
151
+ window.intentShim = new IntentShim();
152
+ window.plugins = window.plugins || {};
153
+ window.plugins.intentShim = window.intentShim;
154
+
155
+ module.exports = {
156
+ ACTION_SEND: IntentShim.prototype.ACTION_SEND,
157
+ ACTION_VIEW: IntentShim.prototype.ACTION_VIEW,
158
+ ACTION_INSTALL_PACKAGE: IntentShim.prototype.ACTION_INSTALL_PACKAGE,
159
+ ACTION_UNINSTALL_PACKAGE: IntentShim.prototype.ACTION_UNINSTALL_PACKAGE,
160
+ EXTRA_TEXT: IntentShim.prototype.EXTRA_TEXT,
161
+ EXTRA_SUBJECT: IntentShim.prototype.EXTRA_SUBJECT,
162
+ EXTRA_STREAM: IntentShim.prototype.EXTRA_STREAM,
163
+ EXTRA_EMAIL: IntentShim.prototype.EXTRA_EMAIL,
164
+ ACTION_CALL: IntentShim.prototype.ACTION_CALL,
165
+ ACTION_SENDTO: IntentShim.prototype.ACTION_SENDTO,
166
+ ACTION_GET_CONTENT: IntentShim.prototype.ACTION_GET_CONTENT,
167
+ ACTION_PICK: IntentShim.prototype.ACTION_PICK,
168
+ RESULT_CANCELED: IntentShim.prototype.RESULT_CANCELED,
169
+ RESULT_OK: IntentShim.prototype.RESULT_OK,
170
+
171
+ startActivity: function (params, successCallback, errorCallback) {
172
+ argscheck.checkArgs('off', 'IntentShim.startActivity', arguments);
173
+ exec(successCallback, errorCallback, "IntentShim", "startActivity", [params]);
174
+ },
175
+
176
+ startActivityForResult: function (params, successCallback, errorCallback) {
177
+ argscheck.checkArgs('off', 'IntentShim.startActivityForResult', arguments);
178
+ exec(successCallback, errorCallback, "IntentShim", "startActivityForResult", [params]);
179
+ },
180
+
181
+ sendBroadcast: function (params, successCallback, errorCallback) {
182
+ argscheck.checkArgs('off', 'IntentShim.sendBroadcast', arguments);
183
+ exec(successCallback, errorCallback, "IntentShim", "sendBroadcast", [params]);
184
+ },
185
+
186
+ startService: function (params, successCallback, errorCallback) {
187
+ argscheck.checkArgs('off', 'IntentShim.startService', arguments);
188
+ exec(successCallback, errorCallback, "IntentShim", "startService", [params]);
189
+ },
190
+
191
+ registerBroadcastReceiver: function (params, callback) {
192
+ argscheck.checkArgs('of', 'IntentShim.registerBroadcastReceiver', arguments);
193
+ exec(callback, null, "IntentShim", "registerBroadcastReceiver", [params]);
194
+ },
195
+
196
+ unregisterBroadcastReceiver: function () {
197
+ argscheck.checkArgs('', 'IntentShim.unregisterBroadcastReceiver', arguments);
198
+ exec(null, null, "IntentShim", "unregisterBroadcastReceiver", []);
199
+ },
200
+
201
+ onIntent: function (callback) {
202
+ argscheck.checkArgs('f', 'IntentShim.onIntent', arguments);
203
+ exec(callback, null, "IntentShim", "onIntent", [callback]);
204
+ },
205
+
206
+ onActivityResult: function (callback) {
207
+ argscheck.checkArgs('f', 'IntentShim.onActivityResult', arguments);
208
+ exec(callback, null, "IntentShim", "onActivityResult", [callback]);
209
+ },
210
+
211
+ getIntent: function (successCallback, failureCallback) {
212
+ argscheck.checkArgs('ff', 'IntentShim.getIntent', arguments);
213
+ exec(successCallback, failureCallback, "IntentShim", "getIntent", []);
214
+ },
215
+
216
+ sendResult: function (params, callback) {
217
+ argscheck.checkArgs('of', 'IntentShim.sendResult', arguments);
218
+ exec(callback, null, "IntentShim", "sendResult", [params]);
219
+ },
220
+
221
+ realPathFromUri: function (params, successCallback, errorCallback) {
222
+ argscheck.checkArgs('off', 'IntentShim.realPathFromUri', arguments);
223
+ exec(successCallback, errorCallback, "IntentShim", "realPathFromUri", [params]);
224
+ },
225
+
226
+ packageExists: function (packageName, successCallback) {
227
+ argscheck.checkArgs('sf', 'IntentShim.packageExists', arguments);
228
+ exec(successCallback, null, "IntentShim", "packageExists", [packageName]);
229
+ },
230
+
231
+ /**
232
+ * Check and request necessary permissions for Android 13+
233
+ *
234
+ * @param {Function} successCallback - Function to call on success
235
+ * @param {Function} errorCallback - Function to call on error
236
+ */
237
+ checkAndRequestPermissions: function (successCallback, errorCallback) {
238
+ if (cordova.platformId === 'android') {
239
+ cordova.exec(
240
+ successCallback,
241
+ errorCallback,
242
+ "IntentShim",
243
+ "checkAndRequestPermissions",
244
+ []
245
+ );
246
+ } else {
247
+ // Non-Android platforms don't need these specific permissions
248
+ successCallback();
249
+ }
250
+ },
251
+
252
+ /**
253
+ * Modified startActivity to handle permissions for Android 13+
254
+ */
255
+ startActivity: function (params, successCallback, errorCallback) {
256
+ // First check permissions, then proceed with action
257
+ this.checkAndRequestPermissions(
258
+ function () {
259
+ cordova.exec(
260
+ successCallback,
261
+ errorCallback,
262
+ "IntentShim",
263
+ "startActivity",
264
+ [params]
265
+ );
266
+ },
267
+ errorCallback
268
+ );
269
+ },
270
+
271
+ /**
272
+ * Modified startActivityForResult to handle permissions for Android 13+
273
+ */
274
+ startActivityForResult: function (params, successCallback, errorCallback) {
275
+ // First check permissions, then proceed with action
276
+ this.checkAndRequestPermissions(
277
+ function () {
278
+ cordova.exec(
279
+ successCallback,
280
+ errorCallback,
281
+ "IntentShim",
282
+ "startActivityForResult",
283
+ [params]
284
+ );
285
+ },
286
+ errorCallback
287
+ );
288
+ },
289
+ };
@@ -1,36 +0,0 @@
1
- ext {
2
- junitVersion = '4.12'
3
- androidxAppCompatVersion = '1.2.0'
4
- androidxJunitVersion = '1.1.2'
5
- androidxEspressoCoreVersion = '3.3.0'
6
- }
7
-
8
- apply plugin: 'com.android.library'
9
-
10
- android {
11
- compileSdkVersion 31
12
- defaultConfig {
13
- minSdkVersion 22
14
- targetSdkVersion 31
15
- versionCode 1
16
- versionName "1.0"
17
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18
- }
19
- buildTypes {
20
- release {
21
- minifyEnabled false
22
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23
- }
24
- }
25
- lintOptions {
26
- abortOnError false
27
- }
28
- }
29
-
30
- dependencies {
31
- implementation fileTree(dir: 'libs', include: ['*.jar'])
32
- implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
33
- testImplementation "junit:junit:$junitVersion"
34
- androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
35
- androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
36
- }
@@ -1,21 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- package="com.getcapacitor.community.intentshim">
4
-
5
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
6
- <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
7
- <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
8
- <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
9
-
10
- <application>
11
- <provider
12
- android:name="com.getcapacitor.community.intentshim.IntentFileProvider"
13
- android:authorities="${applicationId}.intentshim.fileprovider"
14
- android:exported="false"
15
- android:grantUriPermissions="true">
16
- <meta-data
17
- android:name="android.support.FILE_PROVIDER_PATHS"
18
- android:resource="@xml/provider_paths" />
19
- </provider>
20
- </application>
21
- </manifest>
@@ -1,13 +0,0 @@
1
- export interface IntentShimPlugin {
2
- startActivity(options: { url: string }): Promise<{ value: string }>;
3
- sendBroadcast(options: { action: string, extras: { [key: string]: any } }): Promise<void>;
4
- registerBroadcastReceiver(options: { filterActions: string[], filterCategories: string[], filterDataSchemes: string[] }, callback: (message: any) => void): Promise<string>;
5
- unregisterBroadcastReceiver(options: { callbackId: string }): Promise<void>;
6
- onIntent(callback: (message: any) => void): Promise<string>;
7
- onActivityResult(callback: (message: any) => void): Promise<string>;
8
- getIntent(): Promise<any>;
9
- sendResult(options: { extras: { [key: string]: any } }): Promise<void>;
10
- realPathFromUri(options: { uri: string }): Promise<{ value: string }>;
11
- packageExists(options: { packageName: string }): Promise<{ value: boolean }>;
12
- checkAndRequestPermissions(): Promise<void>;
13
- }
package/src/index.ts DELETED
@@ -1,10 +0,0 @@
1
- import { registerPlugin } from '@capacitor/core';
2
-
3
- import type { IntentShimPlugin } from './definitions';
4
-
5
- const IntentShim = registerPlugin<IntentShimPlugin>('IntentShim', {
6
- web: () => import('./web').then(m => new m.IntentShimWeb()),
7
- });
8
-
9
- export * from './definitions';
10
- export { IntentShim };
package/src/web.ts DELETED
@@ -1,58 +0,0 @@
1
- import { WebPlugin } from '@capacitor/core';
2
-
3
- import type { IntentShimPlugin } from './definitions';
4
-
5
- export class IntentShimWeb extends WebPlugin implements IntentShimPlugin {
6
- async startActivity(options: { url: string }): Promise<{ value: string }> {
7
- console.log('startActivity', options);
8
- throw this.unimplemented('Not implemented on web.');
9
- }
10
-
11
- async sendBroadcast(options: { action: string, extras: { [key: string]: any } }): Promise<void> {
12
- console.log('sendBroadcast', options);
13
- throw this.unimplemented('Not implemented on web.');
14
- }
15
-
16
- async registerBroadcastReceiver(options: { filterActions: string[], filterCategories: string[], filterDataSchemes: string[] }, callback: (message: any) => void): Promise<string> {
17
- console.log('registerBroadcastReceiver', options, callback);
18
- throw this.unimplemented('Not implemented on web.');
19
- }
20
-
21
- async unregisterBroadcastReceiver(options: { callbackId: string }): Promise<void> {
22
- console.log('unregisterBroadcastReceiver', options);
23
- throw this.unimplemented('Not implemented on web.');
24
- }
25
-
26
- async onIntent(callback: (message: any) => void): Promise<string> {
27
- console.log('onIntent', callback);
28
- throw this.unimplemented('Not implemented on web.');
29
- }
30
-
31
- async onActivityResult(callback: (message: any) => void): Promise<string> {
32
- console.log('onActivityResult', callback);
33
- throw this.unimplemented('Not implemented on web.');
34
- }
35
-
36
- async getIntent(): Promise<any> {
37
- throw this.unimplemented('Not implemented on web.');
38
- }
39
-
40
- async sendResult(options: { extras: { [key: string]: any } }): Promise<void> {
41
- console.log('sendResult', options);
42
- throw this.unimplemented('Not implemented on web.');
43
- }
44
-
45
- async realPathFromUri(options: { uri: string }): Promise<{ value: string }> {
46
- console.log('realPathFromUri', options);
47
- throw this.unimplemented('Not implemented on web.');
48
- }
49
-
50
- async packageExists(options: { packageName: string }): Promise<{ value: boolean }> {
51
- console.log('packageExists', options);
52
- throw this.unimplemented('Not implemented on web.');
53
- }
54
-
55
- async checkAndRequestPermissions(): Promise<void> {
56
- throw this.unimplemented('Not implemented on web.');
57
- }
58
- }
@@ -1,40 +0,0 @@
1
- export interface IntentShimPlugin {
2
- startActivity(options: {
3
- url: string;
4
- }): Promise<{
5
- value: string;
6
- }>;
7
- sendBroadcast(options: {
8
- action: string;
9
- extras: {
10
- [key: string]: any;
11
- };
12
- }): Promise<void>;
13
- registerBroadcastReceiver(options: {
14
- filterActions: string[];
15
- filterCategories: string[];
16
- filterDataSchemes: string[];
17
- }, callback: (message: any) => void): Promise<string>;
18
- unregisterBroadcastReceiver(options: {
19
- callbackId: string;
20
- }): Promise<void>;
21
- onIntent(callback: (message: any) => void): Promise<string>;
22
- onActivityResult(callback: (message: any) => void): Promise<string>;
23
- getIntent(): Promise<any>;
24
- sendResult(options: {
25
- extras: {
26
- [key: string]: any;
27
- };
28
- }): Promise<void>;
29
- realPathFromUri(options: {
30
- uri: string;
31
- }): Promise<{
32
- value: string;
33
- }>;
34
- packageExists(options: {
35
- packageName: string;
36
- }): Promise<{
37
- value: boolean;
38
- }>;
39
- checkAndRequestPermissions(): Promise<void>;
40
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=definitions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface IntentShimPlugin {\n startActivity(options: { url: string }): Promise<{ value: string }>;\n sendBroadcast(options: { action: string, extras: { [key: string]: any } }): Promise<void>;\n registerBroadcastReceiver(options: { filterActions: string[], filterCategories: string[], filterDataSchemes: string[] }, callback: (message: any) => void): Promise<string>;\n unregisterBroadcastReceiver(options: { callbackId: string }): Promise<void>;\n onIntent(callback: (message: any) => void): Promise<string>;\n onActivityResult(callback: (message: any) => void): Promise<string>;\n getIntent(): Promise<any>;\n sendResult(options: { extras: { [key: string]: any } }): Promise<void>;\n realPathFromUri(options: { uri: string }): Promise<{ value: string }>;\n packageExists(options: { packageName: string }): Promise<{ value: boolean }>;\n checkAndRequestPermissions(): Promise<void>;\n}\n"]}
package/www/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { IntentShimPlugin } from './definitions';
2
- declare const IntentShim: IntentShimPlugin;
3
- export * from './definitions';
4
- export { IntentShim };
package/www/index.js DELETED
@@ -1,7 +0,0 @@
1
- import { registerPlugin } from '@capacitor/core';
2
- const IntentShim = registerPlugin('IntentShim', {
3
- web: () => import('./web').then(m => new m.IntentShimWeb()),
4
- });
5
- export * from './definitions';
6
- export { IntentShim };
7
- //# sourceMappingURL=index.js.map
package/www/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,UAAU,GAAG,cAAc,CAAmB,YAAY,EAAE;IAChE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;CAC5D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { IntentShimPlugin } from './definitions';\n\nconst IntentShim = registerPlugin<IntentShimPlugin>('IntentShim', {\n web: () => import('./web').then(m => new m.IntentShimWeb()),\n});\n\nexport * from './definitions';\nexport { IntentShim };\n"]}
package/www/web.d.ts DELETED
@@ -1,42 +0,0 @@
1
- import { WebPlugin } from '@capacitor/core';
2
- import type { IntentShimPlugin } from './definitions';
3
- export declare class IntentShimWeb extends WebPlugin implements IntentShimPlugin {
4
- startActivity(options: {
5
- url: string;
6
- }): Promise<{
7
- value: string;
8
- }>;
9
- sendBroadcast(options: {
10
- action: string;
11
- extras: {
12
- [key: string]: any;
13
- };
14
- }): Promise<void>;
15
- registerBroadcastReceiver(options: {
16
- filterActions: string[];
17
- filterCategories: string[];
18
- filterDataSchemes: string[];
19
- }, callback: (message: any) => void): Promise<string>;
20
- unregisterBroadcastReceiver(options: {
21
- callbackId: string;
22
- }): Promise<void>;
23
- onIntent(callback: (message: any) => void): Promise<string>;
24
- onActivityResult(callback: (message: any) => void): Promise<string>;
25
- getIntent(): Promise<any>;
26
- sendResult(options: {
27
- extras: {
28
- [key: string]: any;
29
- };
30
- }): Promise<void>;
31
- realPathFromUri(options: {
32
- uri: string;
33
- }): Promise<{
34
- value: string;
35
- }>;
36
- packageExists(options: {
37
- packageName: string;
38
- }): Promise<{
39
- value: boolean;
40
- }>;
41
- checkAndRequestPermissions(): Promise<void>;
42
- }
package/www/web.js DELETED
@@ -1,46 +0,0 @@
1
- import { WebPlugin } from '@capacitor/core';
2
- export class IntentShimWeb extends WebPlugin {
3
- async startActivity(options) {
4
- console.log('startActivity', options);
5
- throw this.unimplemented('Not implemented on web.');
6
- }
7
- async sendBroadcast(options) {
8
- console.log('sendBroadcast', options);
9
- throw this.unimplemented('Not implemented on web.');
10
- }
11
- async registerBroadcastReceiver(options, callback) {
12
- console.log('registerBroadcastReceiver', options, callback);
13
- throw this.unimplemented('Not implemented on web.');
14
- }
15
- async unregisterBroadcastReceiver(options) {
16
- console.log('unregisterBroadcastReceiver', options);
17
- throw this.unimplemented('Not implemented on web.');
18
- }
19
- async onIntent(callback) {
20
- console.log('onIntent', callback);
21
- throw this.unimplemented('Not implemented on web.');
22
- }
23
- async onActivityResult(callback) {
24
- console.log('onActivityResult', callback);
25
- throw this.unimplemented('Not implemented on web.');
26
- }
27
- async getIntent() {
28
- throw this.unimplemented('Not implemented on web.');
29
- }
30
- async sendResult(options) {
31
- console.log('sendResult', options);
32
- throw this.unimplemented('Not implemented on web.');
33
- }
34
- async realPathFromUri(options) {
35
- console.log('realPathFromUri', options);
36
- throw this.unimplemented('Not implemented on web.');
37
- }
38
- async packageExists(options) {
39
- console.log('packageExists', options);
40
- throw this.unimplemented('Not implemented on web.');
41
- }
42
- async checkAndRequestPermissions() {
43
- throw this.unimplemented('Not implemented on web.');
44
- }
45
- }
46
- //# sourceMappingURL=web.js.map
package/www/web.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,KAAK,CAAC,aAAa,CAAC,OAAwB;QAC1C,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QACtC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAA2D;QAC7E,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QACtC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,yBAAyB,CAAC,OAA6F,EAAE,QAAgC;QAC7J,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC5D,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,2BAA2B,CAAC,OAA+B;QAC/D,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;QACpD,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAgC;QAC7C,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAClC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,QAAgC;QACrD,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QAC1C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAA2C;QAC1D,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAAwB;QAC5C,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;QACxC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAgC;QAClD,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QACtC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,0BAA0B;QAC9B,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { IntentShimPlugin } from './definitions';\n\nexport class IntentShimWeb extends WebPlugin implements IntentShimPlugin {\n async startActivity(options: { url: string }): Promise<{ value: string }> {\n console.log('startActivity', options);\n throw this.unimplemented('Not implemented on web.');\n }\n\n async sendBroadcast(options: { action: string, extras: { [key: string]: any } }): Promise<void> {\n console.log('sendBroadcast', options);\n throw this.unimplemented('Not implemented on web.');\n }\n\n async registerBroadcastReceiver(options: { filterActions: string[], filterCategories: string[], filterDataSchemes: string[] }, callback: (message: any) => void): Promise<string> {\n console.log('registerBroadcastReceiver', options, callback);\n throw this.unimplemented('Not implemented on web.');\n }\n\n async unregisterBroadcastReceiver(options: { callbackId: string }): Promise<void> {\n console.log('unregisterBroadcastReceiver', options);\n throw this.unimplemented('Not implemented on web.');\n }\n\n async onIntent(callback: (message: any) => void): Promise<string> {\n console.log('onIntent', callback);\n throw this.unimplemented('Not implemented on web.');\n }\n\n async onActivityResult(callback: (message: any) => void): Promise<string> {\n console.log('onActivityResult', callback);\n throw this.unimplemented('Not implemented on web.');\n }\n\n async getIntent(): Promise<any> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async sendResult(options: { extras: { [key: string]: any } }): Promise<void> {\n console.log('sendResult', options);\n throw this.unimplemented('Not implemented on web.');\n }\n\n async realPathFromUri(options: { uri: string }): Promise<{ value: string }> {\n console.log('realPathFromUri', options);\n throw this.unimplemented('Not implemented on web.');\n }\n\n async packageExists(options: { packageName: string }): Promise<{ value: boolean }> {\n console.log('packageExists', options);\n throw this.unimplemented('Not implemented on web.');\n }\n\n async checkAndRequestPermissions(): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"]}