@iotize/device-com-nfc.cordova 3.8.1 → 3.8.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.
Files changed (62) hide show
  1. package/LICENSE +30 -30
  2. package/README.md +673 -673
  3. package/bundles/iotize-device-com-nfc.cordova.umd.js +946 -967
  4. package/bundles/iotize-device-com-nfc.cordova.umd.js.map +1 -1
  5. package/bundles/iotize-device-com-nfc.cordova.umd.min.js +1 -1
  6. package/bundles/iotize-device-com-nfc.cordova.umd.min.js.map +1 -1
  7. package/esm2015/iotize-device-com-nfc.cordova.js +4 -4
  8. package/esm2015/public_api.js +1 -1
  9. package/esm2015/www/cordova-interface.js +1 -1
  10. package/esm2015/www/errors.js +30 -30
  11. package/esm2015/www/errors.js.map +1 -1
  12. package/esm2015/www/index.js +6 -6
  13. package/esm2015/www/index.js.map +1 -1
  14. package/esm2015/www/logger.js +2 -2
  15. package/esm2015/www/logger.js.map +1 -1
  16. package/esm2015/www/ndef/definitions.js +16 -16
  17. package/esm2015/www/ndef/definitions.js.map +1 -1
  18. package/esm2015/www/ndef/parse-ndef-message.js +164 -164
  19. package/esm2015/www/ndef/parse-ndef-message.js.map +1 -1
  20. package/esm2015/www/nfc-com-protocol.js +169 -169
  21. package/esm2015/www/tap-ndef/definitions.js +1 -1
  22. package/esm2015/www/tap-ndef/definitions.js.map +1 -1
  23. package/esm2015/www/tap-ndef/index.js +2 -2
  24. package/esm2015/www/tap-ndef/index.js.map +1 -1
  25. package/esm2015/www/tap-ndef/parse-ndef-message.js +51 -51
  26. package/esm2015/www/tap-ndef/parse-ndef-message.js.map +1 -1
  27. package/esm2015/www/utility.js +10 -10
  28. package/esm2015/www/utility.js.map +1 -1
  29. package/esm2015/www/utility.ngsummary.json +1 -1
  30. package/fesm2015/iotize-device-com-nfc.cordova.js +425 -425
  31. package/fesm2015/iotize-device-com-nfc.cordova.js.map +1 -1
  32. package/iotize-device-com-nfc.cordova.d.ts +4 -4
  33. package/package.json +1 -1
  34. package/public_api.d.ts +1 -1
  35. package/src/android/.gradle/4.10.1/fileChanges/last-build.bin +0 -0
  36. package/src/android/.gradle/4.10.1/fileHashes/fileHashes.bin +0 -0
  37. package/src/android/.gradle/4.10.1/fileHashes/fileHashes.lock +0 -0
  38. package/src/android/.gradle/4.10.1/gc.properties +0 -0
  39. package/src/android/.gradle/vcs-1/gc.properties +0 -0
  40. package/src/android/build.gradle +38 -38
  41. package/src/android/gradle/wrapper/gradle-wrapper.properties +6 -6
  42. package/src/android/gradlew +172 -172
  43. package/src/android/gradlew.bat +84 -84
  44. package/src/android/local.properties +8 -8
  45. package/src/android/src/com/chariotsolutions/nfc/plugin/JSONBuilder.java +60 -60
  46. package/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java +92 -81
  47. package/src/android/src/com/chariotsolutions/nfc/plugin/NfcPluginError.java +15 -15
  48. package/src/android/src/com/chariotsolutions/nfc/plugin/PluginResponse.java +85 -85
  49. package/src/android/src/com/chariotsolutions/nfc/plugin/Util.java +140 -140
  50. package/src/ios/NFCTagReader.swift +32 -2
  51. package/src/ios/NFCTapPlugin.swift +57 -1
  52. package/www/cordova-interface.d.ts +34 -34
  53. package/www/errors.d.ts +17 -17
  54. package/www/index.d.ts +6 -6
  55. package/www/logger.d.ts +2 -2
  56. package/www/ndef/definitions.d.ts +15 -15
  57. package/www/ndef/parse-ndef-message.d.ts +69 -69
  58. package/www/nfc-com-protocol.d.ts +36 -36
  59. package/www/tap-ndef/definitions.d.ts +25 -25
  60. package/www/tap-ndef/index.d.ts +2 -2
  61. package/www/tap-ndef/parse-ndef-message.d.ts +6 -6
  62. package/www/utility.d.ts +2 -2
@@ -1,84 +1,84 @@
1
- @if "%DEBUG%" == "" @echo off
2
- @rem ##########################################################################
3
- @rem
4
- @rem Gradle startup script for Windows
5
- @rem
6
- @rem ##########################################################################
7
-
8
- @rem Set local scope for the variables with windows NT shell
9
- if "%OS%"=="Windows_NT" setlocal
10
-
11
- set DIRNAME=%~dp0
12
- if "%DIRNAME%" == "" set DIRNAME=.
13
- set APP_BASE_NAME=%~n0
14
- set APP_HOME=%DIRNAME%
15
-
16
- @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17
- set DEFAULT_JVM_OPTS=
18
-
19
- @rem Find java.exe
20
- if defined JAVA_HOME goto findJavaFromJavaHome
21
-
22
- set JAVA_EXE=java.exe
23
- %JAVA_EXE% -version >NUL 2>&1
24
- if "%ERRORLEVEL%" == "0" goto init
25
-
26
- echo.
27
- echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
- echo.
29
- echo Please set the JAVA_HOME variable in your environment to match the
30
- echo location of your Java installation.
31
-
32
- goto fail
33
-
34
- :findJavaFromJavaHome
35
- set JAVA_HOME=%JAVA_HOME:"=%
36
- set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
-
38
- if exist "%JAVA_EXE%" goto init
39
-
40
- echo.
41
- echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
- echo.
43
- echo Please set the JAVA_HOME variable in your environment to match the
44
- echo location of your Java installation.
45
-
46
- goto fail
47
-
48
- :init
49
- @rem Get command-line arguments, handling Windows variants
50
-
51
- if not "%OS%" == "Windows_NT" goto win9xME_args
52
-
53
- :win9xME_args
54
- @rem Slurp the command line arguments.
55
- set CMD_LINE_ARGS=
56
- set _SKIP=2
57
-
58
- :win9xME_args_slurp
59
- if "x%~1" == "x" goto execute
60
-
61
- set CMD_LINE_ARGS=%*
62
-
63
- :execute
64
- @rem Setup the command line
65
-
66
- set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67
-
68
- @rem Execute Gradle
69
- "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70
-
71
- :end
72
- @rem End local scope for the variables with windows NT shell
73
- if "%ERRORLEVEL%"=="0" goto mainEnd
74
-
75
- :fail
76
- rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77
- rem the _cmd.exe /c_ return code!
78
- if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79
- exit /b 1
80
-
81
- :mainEnd
82
- if "%OS%"=="Windows_NT" endlocal
83
-
84
- :omega
1
+ @if "%DEBUG%" == "" @echo off
2
+ @rem ##########################################################################
3
+ @rem
4
+ @rem Gradle startup script for Windows
5
+ @rem
6
+ @rem ##########################################################################
7
+
8
+ @rem Set local scope for the variables with windows NT shell
9
+ if "%OS%"=="Windows_NT" setlocal
10
+
11
+ set DIRNAME=%~dp0
12
+ if "%DIRNAME%" == "" set DIRNAME=.
13
+ set APP_BASE_NAME=%~n0
14
+ set APP_HOME=%DIRNAME%
15
+
16
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17
+ set DEFAULT_JVM_OPTS=
18
+
19
+ @rem Find java.exe
20
+ if defined JAVA_HOME goto findJavaFromJavaHome
21
+
22
+ set JAVA_EXE=java.exe
23
+ %JAVA_EXE% -version >NUL 2>&1
24
+ if "%ERRORLEVEL%" == "0" goto init
25
+
26
+ echo.
27
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
+ echo.
29
+ echo Please set the JAVA_HOME variable in your environment to match the
30
+ echo location of your Java installation.
31
+
32
+ goto fail
33
+
34
+ :findJavaFromJavaHome
35
+ set JAVA_HOME=%JAVA_HOME:"=%
36
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
+
38
+ if exist "%JAVA_EXE%" goto init
39
+
40
+ echo.
41
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
+ echo.
43
+ echo Please set the JAVA_HOME variable in your environment to match the
44
+ echo location of your Java installation.
45
+
46
+ goto fail
47
+
48
+ :init
49
+ @rem Get command-line arguments, handling Windows variants
50
+
51
+ if not "%OS%" == "Windows_NT" goto win9xME_args
52
+
53
+ :win9xME_args
54
+ @rem Slurp the command line arguments.
55
+ set CMD_LINE_ARGS=
56
+ set _SKIP=2
57
+
58
+ :win9xME_args_slurp
59
+ if "x%~1" == "x" goto execute
60
+
61
+ set CMD_LINE_ARGS=%*
62
+
63
+ :execute
64
+ @rem Setup the command line
65
+
66
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67
+
68
+ @rem Execute Gradle
69
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70
+
71
+ :end
72
+ @rem End local scope for the variables with windows NT shell
73
+ if "%ERRORLEVEL%"=="0" goto mainEnd
74
+
75
+ :fail
76
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77
+ rem the _cmd.exe /c_ return code!
78
+ if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79
+ exit /b 1
80
+
81
+ :mainEnd
82
+ if "%OS%"=="Windows_NT" endlocal
83
+
84
+ :omega
@@ -1,8 +1,8 @@
1
- ## This file must *NOT* be checked into Version Control Systems,
2
- # as it contains information specific to your local configuration.
3
- #
4
- # Location of the SDK. This is only used by Gradle.
5
- # For customization when using a Version Control System, please read the
6
- # header note.
7
- #Mon Dec 09 16:00:29 CET 2019
8
- sdk.dir=C\:\\Android\\android-sdk
1
+ ## This file must *NOT* be checked into Version Control Systems,
2
+ # as it contains information specific to your local configuration.
3
+ #
4
+ # Location of the SDK. This is only used by Gradle.
5
+ # For customization when using a Version Control System, please read the
6
+ # header note.
7
+ #Mon Dec 09 16:00:29 CET 2019
8
+ sdk.dir=C\:\\Android\\android-sdk
@@ -1,60 +1,60 @@
1
- //
2
- // Copyright 2018 IoTize SAS Inc. Licensed under the MIT license.
3
- //
4
- // JSONBuilder.java
5
- // device-com-ble.cordova BLE Cordova Plugin
6
- //
7
- package com.chariotsolutions.nfc.plugin;
8
-
9
- import android.util.Log;
10
-
11
- import com.iotize.android.device.device.impl.IoTizeDevice;
12
-
13
- import org.json.JSONException;
14
- import org.json.JSONObject;
15
-
16
- import io.reactivex.annotations.NonNull;
17
- import io.reactivex.annotations.Nullable;
18
-
19
- public class JSONBuilder {
20
-
21
- private static final String TAG = "JSONBuilder";
22
-
23
- @NonNull
24
- public static JSONObject toJSONObject(NfcPluginError error) {
25
- try {
26
- JSONObject json = new JSONObject();
27
-
28
- json.put("code", error.getCode());
29
- json.put("message", error.getMessage());
30
-
31
- return json;
32
- } catch (JSONException e) {
33
- Log.e(TAG, "Internal error", e);
34
- throw new Error("INTERNAL ERROR: " + e.getMessage(), e);
35
- }
36
- }
37
-
38
- @Nullable
39
- public static JSONObject toJSONObject(@Nullable IoTizeDevice tap) {
40
- if (tap != null) {
41
- try {
42
- // byte[] sessionKey = tap.getSessionKey();
43
- byte[] initializationVector = null; // TODO
44
- JSONObject json = new JSONObject();
45
-
46
- // json.put("sessionKey", sessionKey);
47
- json.put("initializationVector", initializationVector);
48
- json.put("name", "TODO");
49
- json.put("nfcPairingDone", true);
50
-
51
- return json;
52
- } catch (JSONException e) {
53
- Log.e(TAG, "Internal error", e);
54
- throw new Error("INTERNAL ERROR: " + e.getMessage(), e);
55
- }
56
- } else {
57
- return null;
58
- }
59
- }
60
- }
1
+ //
2
+ // Copyright 2018 IoTize SAS Inc. Licensed under the MIT license.
3
+ //
4
+ // JSONBuilder.java
5
+ // device-com-ble.cordova BLE Cordova Plugin
6
+ //
7
+ package com.chariotsolutions.nfc.plugin;
8
+
9
+ import android.util.Log;
10
+
11
+ import com.iotize.android.device.device.impl.IoTizeDevice;
12
+
13
+ import org.json.JSONException;
14
+ import org.json.JSONObject;
15
+
16
+ import io.reactivex.annotations.NonNull;
17
+ import io.reactivex.annotations.Nullable;
18
+
19
+ public class JSONBuilder {
20
+
21
+ private static final String TAG = "JSONBuilder";
22
+
23
+ @NonNull
24
+ public static JSONObject toJSONObject(NfcPluginError error) {
25
+ try {
26
+ JSONObject json = new JSONObject();
27
+
28
+ json.put("code", error.getCode());
29
+ json.put("message", error.getMessage());
30
+
31
+ return json;
32
+ } catch (JSONException e) {
33
+ Log.e(TAG, "Internal error", e);
34
+ throw new Error("INTERNAL ERROR: " + e.getMessage(), e);
35
+ }
36
+ }
37
+
38
+ @Nullable
39
+ public static JSONObject toJSONObject(@Nullable IoTizeDevice tap) {
40
+ if (tap != null) {
41
+ try {
42
+ // byte[] sessionKey = tap.getSessionKey();
43
+ byte[] initializationVector = null; // TODO
44
+ JSONObject json = new JSONObject();
45
+
46
+ // json.put("sessionKey", sessionKey);
47
+ json.put("initializationVector", initializationVector);
48
+ json.put("name", "TODO");
49
+ json.put("nfcPairingDone", true);
50
+
51
+ return json;
52
+ } catch (JSONException e) {
53
+ Log.e(TAG, "Internal error", e);
54
+ throw new Error("INTERNAL ERROR: " + e.getMessage(), e);
55
+ }
56
+ } else {
57
+ return null;
58
+ }
59
+ }
60
+ }
@@ -131,104 +131,117 @@ public class NfcPlugin extends CordovaPlugin {
131
131
 
132
132
  @Override
133
133
  public boolean execute(String action, JSONArray data, CallbackContext callbackContext) throws JSONException {
134
+ try {
135
+ Log.d(TAG, "execute " + action);
134
136
 
135
- Log.d(TAG, "execute " + action);
136
-
137
- // showSettings can be called if NFC is disabled
138
- // might want to skip this if NO_NFC
139
- if (action.equalsIgnoreCase(SHOW_SETTINGS)) {
140
- showSettings(callbackContext);
141
- return true;
142
- }
137
+ // showSettings can be called if NFC is disabled
138
+ // might want to skip this if NO_NFC
139
+ if (action.equalsIgnoreCase(SHOW_SETTINGS)) {
140
+ showSettings(callbackContext);
141
+ return true;
142
+ }
143
143
 
144
- // the channel is set up when the plugin starts
145
- if (action.equalsIgnoreCase(CHANNEL)) {
146
- channelCallback = callbackContext;
147
- return true; // short circuit
148
- }
144
+ // the channel is set up when the plugin starts
145
+ if (action.equalsIgnoreCase(CHANNEL)) {
146
+ channelCallback = callbackContext;
147
+ return true; // short circuit
148
+ }
149
149
 
150
- if (!getNfcStatus().equals(STATUS_NFC_OK)) {
151
- callbackContext.error(getNfcStatus());
152
- return true; // short circuit
153
- }
150
+ if (!getNfcStatus().equals(STATUS_NFC_OK)) {
151
+ callbackContext.error(getNfcStatus());
152
+ return true; // short circuit
153
+ }
154
154
 
155
- createPendingIntent();
155
+ createPendingIntent();
156
156
 
157
- if (action.equalsIgnoreCase(READER_MODE)) {
158
- int flags = data.getInt(0);
159
- readerMode(flags, callbackContext);
157
+ if (action.equalsIgnoreCase(READER_MODE)) {
158
+ int flags = data.getInt(0);
159
+ readerMode(flags, callbackContext);
160
160
 
161
- } else if (action.equalsIgnoreCase(REGISTER_MIME_TYPE)) {
162
- registerMimeType(data, callbackContext);
163
- } else if (action.equalsIgnoreCase(REGISTER_NFC_TAP_DEVICE)) {
161
+ } else if (action.equalsIgnoreCase(REGISTER_MIME_TYPE)) {
162
+ registerMimeType(data, callbackContext);
163
+ } else if (action.equalsIgnoreCase(REGISTER_NFC_TAP_DEVICE)) {
164
164
  // JSONObject jsonStringOptions = data.getJSONObject(0);
165
- registerTapDevice(callbackContext);
166
- } else if (action.equalsIgnoreCase(REMOVE_MIME_TYPE)) {
167
- removeMimeType(data, callbackContext);
165
+ registerTapDevice(callbackContext);
166
+ } else if (action.equalsIgnoreCase(REMOVE_MIME_TYPE)) {
167
+ removeMimeType(data, callbackContext);
168
168
 
169
- } else if (action.equalsIgnoreCase(REGISTER_NDEF)) {
170
- registerNdef(callbackContext);
171
- } else if (action.equalsIgnoreCase(REMOVE_NDEF)) {
172
- removeNdef(callbackContext);
169
+ } else if (action.equalsIgnoreCase(REGISTER_NDEF)) {
170
+ registerNdef(callbackContext);
171
+ } else if (action.equalsIgnoreCase(REMOVE_NDEF)) {
172
+ removeNdef(callbackContext);
173
173
 
174
- } else if (action.equalsIgnoreCase(REGISTER_NDEF_FORMATABLE)) {
175
- registerNdefFormatable(callbackContext);
174
+ } else if (action.equalsIgnoreCase(REGISTER_NDEF_FORMATABLE)) {
175
+ registerNdefFormatable(callbackContext);
176
176
 
177
- } else if (action.equals(REGISTER_DEFAULT_TAG)) {
178
- registerDefaultTag(callbackContext);
177
+ } else if (action.equals(REGISTER_DEFAULT_TAG)) {
178
+ registerDefaultTag(callbackContext);
179
179
 
180
- } else if (action.equals(REMOVE_DEFAULT_TAG)) {
181
- removeDefaultTag(callbackContext);
180
+ } else if (action.equals(REMOVE_DEFAULT_TAG)) {
181
+ removeDefaultTag(callbackContext);
182
182
 
183
- } else if (action.equalsIgnoreCase(WRITE_TAG)) {
184
- writeTag(data, callbackContext);
183
+ } else if (action.equalsIgnoreCase(WRITE_TAG)) {
184
+ writeTag(data, callbackContext);
185
185
 
186
- } else if (action.equalsIgnoreCase(ERASE_TAG)) {
187
- eraseTag(callbackContext);
186
+ } else if (action.equalsIgnoreCase(ERASE_TAG)) {
187
+ eraseTag(callbackContext);
188
188
 
189
- } else if (action.equalsIgnoreCase(INIT)) {
190
- init(callbackContext);
189
+ } else if (action.equalsIgnoreCase(INIT)) {
190
+ init(callbackContext);
191
191
 
192
- } else if (action.equalsIgnoreCase(ENABLED)) {
193
- // status is checked before every call
194
- // if code made it here, NFC is enabled
195
- callbackContext.success(STATUS_NFC_OK);
192
+ } else if (action.equalsIgnoreCase(ENABLED)) {
193
+ // status is checked before every call
194
+ // if code made it here, NFC is enabled
195
+ callbackContext.success(STATUS_NFC_OK);
196
196
 
197
- } else if (action.equalsIgnoreCase(CONNECT_TAP)) {
198
- String tech = data.getString(0);
199
- int timeout = data.optInt(1, -1);
200
- connectTap(tech, timeout, callbackContext);
197
+ } else if (action.equalsIgnoreCase(CONNECT_TAP)) {
198
+ String tech = data.getString(0);
199
+ int timeout = data.optInt(1, -1);
200
+ connectTap(tech, timeout, callbackContext);
201
201
 
202
- } else if (action.equalsIgnoreCase(CONNECT_RAW)) {
203
- String tech = data.getString(0);
204
- int timeout = data.optInt(1, -1);
205
- connectRaw(tech, timeout, callbackContext);
202
+ } else if (action.equalsIgnoreCase(CONNECT_RAW)) {
203
+ String tech = data.getString(0);
204
+ int timeout = data.optInt(1, -1);
205
+ connectRaw(tech, timeout, callbackContext);
206
206
 
207
- } else if (action.equalsIgnoreCase(TRANSCEIVE)) {
208
- CordovaArgs args = new CordovaArgs(data); // execute is using the old signature with JSON data
207
+ } else if (action.equalsIgnoreCase(TRANSCEIVE)) {
208
+ CordovaArgs args = new CordovaArgs(data); // execute is using the old signature with JSON data
209
209
 
210
- byte[] command = args.getArrayBuffer(0);
211
- transceiveRaw(command, callbackContext);
210
+ byte[] command = args.getArrayBuffer(0);
211
+ transceiveRaw(command, callbackContext);
212
212
 
213
- } else if (action.equalsIgnoreCase(TRANSCEIVE_TAP)) {
214
- CordovaArgs args = new CordovaArgs(data); // execute is using the old signature with JSON data
213
+ } else if (action.equalsIgnoreCase(TRANSCEIVE_TAP)) {
214
+ CordovaArgs args = new CordovaArgs(data); // execute is using the old signature with JSON data
215
215
 
216
- byte[] command = args.getArrayBuffer(0);
217
- transceiveTap(command, callbackContext);
216
+ byte[] command = args.getArrayBuffer(0);
217
+ transceiveTap(command, callbackContext);
218
218
 
219
- } else if (action.equalsIgnoreCase(CLOSE)) {
220
- close(callbackContext);
219
+ } else if (action.equalsIgnoreCase(CLOSE)) {
220
+ close(callbackContext);
221
221
 
222
- } else if (action.equalsIgnoreCase(SET_TAP_DEVICE_DISCOVERY_ENABLED)) {
223
- CordovaArgs args = new CordovaArgs(data);
224
- this._isTapDeviceDiscoveryEnabled = args.getBoolean(0);
225
- } else {
226
- // invalid action
227
- callbackContext.error("Invalid NFC action \"" + action +"\"");
228
- return false;
222
+ } else if (action.equalsIgnoreCase(SET_TAP_DEVICE_DISCOVERY_ENABLED)) {
223
+ CordovaArgs args = new CordovaArgs(data);
224
+ this._isTapDeviceDiscoveryEnabled = args.getBoolean(0);
225
+ } else {
226
+ // invalid action
227
+ callbackContext.error("Invalid NFC action \"" + action + "\"");
228
+ return false;
229
+ }
230
+ return true;
231
+ }
232
+ catch (SecurityException err) {
233
+ if (err.getMessage().startsWith("Permission Denial")) {
234
+ callbackContext.error("NFC Tag lost!");
235
+ }
236
+ else {
237
+ callbackContext.error(err.getMessage());
238
+ }
239
+ return true;
240
+ }
241
+ catch (Throwable err) {
242
+ callbackContext.error(err.getMessage());
243
+ return true;
229
244
  }
230
-
231
- return true;
232
245
  }
233
246
 
234
247
  private String getNfcStatus() {
@@ -492,11 +505,9 @@ public class NfcPlugin extends CordovaPlugin {
492
505
  callbackContext.error("Tag doesn't support NDEF");
493
506
  }
494
507
  }
495
- } catch (FormatException e) {
496
- callbackContext.error(e.getMessage());
497
- } catch (TagLostException e) {
498
- callbackContext.error(e.getMessage());
499
- } catch (IOException e) {
508
+ } catch (SecurityException e) {
509
+ callbackContext.error("NFC Tag lost!");
510
+ } catch (Throwable e) {
500
511
  callbackContext.error(e.getMessage());
501
512
  }
502
513
  });
@@ -1054,7 +1065,7 @@ public class NfcPlugin extends CordovaPlugin {
1054
1065
  }
1055
1066
  callbackContext.success();
1056
1067
 
1057
- } catch (Exception ex) {
1068
+ } catch (Throwable ex) {
1058
1069
  Log.e(TAG, "Error closing nfc connection", ex);
1059
1070
  callbackContext.error("Error closing nfc connection " + ex.getLocalizedMessage());
1060
1071
  }
@@ -1142,7 +1153,7 @@ public class NfcPlugin extends CordovaPlugin {
1142
1153
  }
1143
1154
  byte[] response = nfcProtocol.send(data);
1144
1155
  callbackContext.success(Helper.ByteArrayToHexString(response));
1145
- } catch (Exception e) {
1156
+ } catch (Throwable e) {
1146
1157
  Log.e(TAG, e.getMessage(), e);
1147
1158
  callbackContext.error(e.getMessage());
1148
1159
  }
@@ -1,15 +1,15 @@
1
- package com.chariotsolutions.nfc.plugin;
2
-
3
- class NfcPluginError extends Exception {
4
-
5
- String code;
6
-
7
- public String getCode() {
8
- return code;
9
- }
10
-
11
- public NfcPluginError(String code, String message, Throwable cause) {
12
- super(message, cause);
13
- this.code = code;
14
- }
15
- }
1
+ package com.chariotsolutions.nfc.plugin;
2
+
3
+ class NfcPluginError extends Exception {
4
+
5
+ String code;
6
+
7
+ public String getCode() {
8
+ return code;
9
+ }
10
+
11
+ public NfcPluginError(String code, String message, Throwable cause) {
12
+ super(message, cause);
13
+ this.code = code;
14
+ }
15
+ }