cordova-plugin-appice 2.0.8 → 2.0.10

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 (31) hide show
  1. package/README.md +120 -122
  2. package/package.json +45 -27
  3. package/plugin.xml +168 -103
  4. package/scripts/BeforeAndroidBuilt.js +160 -126
  5. package/scripts/BeforeIosBuilt.js +38 -38
  6. package/scripts/androidAfterPluginAdd.js +159 -159
  7. package/scripts/androidAfterPluginRm.js +195 -195
  8. package/scripts/iOSAfterPluginAdd.js +98 -98
  9. package/scripts/iOSAfterPluginRm.js +73 -74
  10. package/src/android/AppICEMFPPush.java +177 -0
  11. package/{libcordova/src/main/java/com/appice/cordova → src/android}/AppICEPlugin.java +405 -489
  12. package/{libcordova/src/main/java/com/appice/cordova → src/android}/CampaignCampsReceiver.java +8 -9
  13. package/{libcordova/src/main/java/com/appice/cordova → src/android}/NotificationEventService.java +16 -7
  14. package/src/build.gradle +16 -14
  15. package/src/firebase/modified/android/FirebasePluginMessagingService.java +356 -356
  16. package/src/firebase/modified/ios/AppDelegate+FirebasePlugin.m +529 -529
  17. package/src/firebase/original/android/FirebasePluginMessagingService.java +348 -348
  18. package/src/firebase/original/ios/AppDelegate+FirebasePlugin.m +519 -519
  19. package/src/ios/AppDelegate+AppICEPlugin.h +8 -8
  20. package/src/ios/AppDelegate+AppICEPlugin.m +278 -191
  21. package/src/ios/AppICEPlugin.h +93 -90
  22. package/src/ios/AppICEPlugin.m +1161 -1062
  23. package/www/AppICE.js +289 -284
  24. package/libcordova/android-release-aar.gradle +0 -63
  25. package/libcordova/build.gradle +0 -50
  26. package/libcordova/cordova.jar +0 -0
  27. package/libcordova/proguard-rules.pro +0 -21
  28. package/libcordova/src/main/AndroidManifest.xml +0 -24
  29. package/libcordova/src/main/res/values/strings.xml +0 -3
  30. package/src/firebase/modified/modified.iml +0 -11
  31. package/src/firebase/original/original.iml +0 -11
@@ -1,12 +1,3 @@
1
- //
2
- // AppICEPlugin.java
3
- //
4
- // AppICE, 08/11/16.
5
- //
6
- // AppICE analytics Plugin for Cordova
7
- // www.appice.io
8
- //
9
-
10
1
  package com.appice.cordova;
11
2
 
12
3
  import android.content.ComponentName;
@@ -14,14 +5,13 @@ import android.content.Context;
14
5
  import android.content.Intent;
15
6
  import android.content.pm.PackageManager;
16
7
  import android.content.pm.ResolveInfo;
8
+ import android.os.Build;
9
+ import android.os.Handler;
10
+ import android.os.Looper;
17
11
  import android.util.DisplayMetrics;
12
+ import android.util.Log;
18
13
  import android.view.View;
19
14
 
20
- //import org.apache.cordova.CallbackContext;
21
- //import org.apache.cordova.CordovaInterface;
22
- //import org.apache.cordova.CordovaPlugin;
23
- //import org.apache.cordova.CordovaWebView;
24
- //import org.apache.cordova.PluginResult;
25
15
  import org.apache.cordova.CallbackContext;
26
16
  import org.apache.cordova.CordovaInterface;
27
17
  import org.apache.cordova.CordovaPlugin;
@@ -34,7 +24,6 @@ import java.lang.annotation.Retention;
34
24
  import java.lang.reflect.Method;
35
25
  import java.util.ArrayList;
36
26
  import java.util.Arrays;
37
- import java.util.Collections;
38
27
  import java.util.HashMap;
39
28
  import java.util.Iterator;
40
29
  import java.util.List;
@@ -45,20 +34,19 @@ import semusi.activitysdk.ContextData;
45
34
  import semusi.activitysdk.ContextSdk;
46
35
  import semusi.activitysdk.SdkConfig;
47
36
  import semusi.activitysdk.User;
48
-
49
37
  import static java.lang.annotation.RetentionPolicy.RUNTIME;
50
38
 
51
39
  public class AppICEPlugin extends CordovaPlugin {
52
- private static final String TAG = "AppICE_CP";
53
-
54
- HashMap<String, CallbackContext> callbackIds = new HashMap<String, CallbackContext>();
55
40
 
41
+ private static final String TAG = AppICEPlugin.class.getSimpleName();
56
42
  private static final Map<String, Method> exportedMethods;
43
+ private static boolean inBackground = true;
44
+ private static ArrayList<JSONObject> notificationStack = null;
45
+ private static CallbackContext notificationCallbackContext;
46
+ private static CallbackContext callbackContext;
57
47
 
58
48
  @Retention(RUNTIME)
59
- @interface CordovaMethod {
60
-
61
- }
49
+ @interface CordovaMethod { }
62
50
 
63
51
  static {
64
52
  HashMap<String, Method> methods = new HashMap<String, Method>();
@@ -69,10 +57,32 @@ public class AppICEPlugin extends CordovaPlugin {
69
57
  methods.put(method.getName(), method);
70
58
  }
71
59
  }
72
-
73
60
  exportedMethods = methods;
74
61
  }
75
62
 
63
+ @Override
64
+ public void onPause(boolean multitasking) {
65
+ AppICEPlugin.inBackground = true;
66
+ }
67
+
68
+ @Override
69
+ public void onResume(boolean multitasking) {
70
+ AppICEPlugin.inBackground = false;
71
+ }
72
+
73
+ @Override
74
+ public void onReset() {
75
+ AppICEPlugin.notificationCallbackContext = null;
76
+ }
77
+
78
+ public static boolean inBackground() {
79
+ return AppICEPlugin.inBackground;
80
+ }
81
+
82
+ public static boolean hasNotificationsCallback() {
83
+ return AppICEPlugin.notificationCallbackContext != null;
84
+ }
85
+
76
86
  @Override
77
87
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
78
88
  super.initialize(cordova, webView);
@@ -80,6 +90,24 @@ public class AppICEPlugin extends CordovaPlugin {
80
90
  onNewIntent(cordova.getActivity().getIntent());
81
91
  }
82
92
 
93
+ @Override
94
+ public boolean execute(String action, JSONArray data, CallbackContext callbackId) {
95
+ Method method = exportedMethods.get(action);
96
+ if (method == null) {
97
+ return false;
98
+ }
99
+
100
+ try {
101
+ Boolean result = (Boolean) method.invoke(this, data, callbackId);
102
+ return true;
103
+ } catch (Throwable e) {
104
+ return false;
105
+ }
106
+ }
107
+
108
+ /*====================================
109
+ // SDK CONFIG SETTING APIS
110
+ //===================================*/
83
111
  @CordovaMethod
84
112
  private void validateIntegration(JSONArray data, CallbackContext callbackContext) {
85
113
  try {
@@ -93,7 +121,9 @@ public class AppICEPlugin extends CordovaPlugin {
93
121
  callbackContext.error("Missing Receiver entry in AndroidManifest : CampaignCampsReceiver");
94
122
 
95
123
  Intent serviceIntent = new Intent();
96
- serviceIntent.setClass(ctx, NotificationEventService.class);
124
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
125
+ serviceIntent.setClass(ctx, NotificationEventService.class);
126
+ }
97
127
  ResolveInfo services = pm.resolveService(serviceIntent, 0);
98
128
  if (services == null)
99
129
  callbackContext.error("Missing Service entry in AndroidManifest : NotificationEventService");
@@ -105,51 +135,21 @@ public class AppICEPlugin extends CordovaPlugin {
105
135
 
106
136
  if (sdk.getAppKey() == null || sdk.getAppKey().length() <= 0 || sdk.getAppKey().trim().length() <= 0) {
107
137
  callbackContext.error("Missing Meta-data entry : AppKey");
108
- return;
109
138
  }
110
139
 
111
140
  if (sdk.getApiKey() == null || sdk.getApiKey().length() <= 0 || sdk.getApiKey().trim().length() <= 0) {
112
141
  callbackContext.error("Missing Meta-data entry : ApiKey");
113
- return;
114
142
  }
115
143
  } catch (Throwable e) {
116
144
  callbackContext.error(e.getMessage());
117
- return;
118
145
  }
119
-
120
146
  callbackContext.success("");
121
- return;
122
- }
123
-
124
- // private void validateCordovaIntegration(Context ctx) {
125
- // try {
126
- // PackageManager pm = ctx.getPackageManager();
127
- //
128
- // Intent receiverIntent = new Intent();
129
- // receiverIntent.setClass(ctx, CampaignCampsReceiver.class);
130
- // List<ResolveInfo> receivers = pm.queryBroadcastReceivers(receiverIntent, 0);
131
- // if (receivers == null || receivers.size() <= 0)
132
- // Toast.makeText(ctx, "Missing Receiver entry in AndroidManifest : CampaignCampsReceiver", Toast.LENGTH_LONG).show();
133
- //
134
- // Intent serviceIntent = new Intent();
135
- // serviceIntent.setClass(ctx, NotificationEventService.class);
136
- // ResolveInfo services = pm.resolveService(serviceIntent, 0);
137
- // if (services == null)
138
- // Toast.makeText(ctx, "Missing Service entry in AndroidManifest : NotificationEventService", Toast.LENGTH_LONG).show();
139
- //
140
- // } catch (Throwable e) {
141
- // e.printStackTrace();
142
- // }
143
- // }
147
+ }
144
148
 
145
149
  @CordovaMethod
146
150
  private void startContext(JSONArray data, CallbackContext callbackContext) {
147
151
  try {
148
- //validateCordovaIntegration(cordova.getActivity().getApplicationContext());
149
-
150
152
  SdkConfig config = new SdkConfig();
151
-
152
- // Init sdk with your config
153
153
  Api.startContext(cordova.getActivity().getApplicationContext(), config);
154
154
 
155
155
  callbackContext.success();
@@ -161,8 +161,6 @@ public class AppICEPlugin extends CordovaPlugin {
161
161
  @CordovaMethod
162
162
  private void initSdk(JSONArray data, CallbackContext callbackContext) {
163
163
  try {
164
- //validateCordovaIntegration(cordova.getActivity().getApplicationContext());
165
-
166
164
  ArrayList<String> listCert = new ArrayList<>();
167
165
  SdkConfig config = new SdkConfig();
168
166
 
@@ -176,22 +174,20 @@ public class AppICEPlugin extends CordovaPlugin {
176
174
  region = root.optString("region");
177
175
  baseUrl = root.optString("baseUrl");
178
176
 
179
- if (root.has("certs")){
177
+ if (root.has("certs")) {
180
178
  JSONArray arr = root.optJSONArray("certs");
181
- if (arr != null){
179
+ if (arr != null) {
182
180
  for (int i = 0; i < arr.length(); i++) {
183
181
  listCert.add(arr.get(i).toString());
184
182
  }
185
183
  }
186
184
  }
187
185
  } catch (Throwable e) {
186
+ Log.e(TAG, "initSdk: error ", e);
188
187
  }
189
188
 
190
189
  config.setAnalyticsTrackingAllowedState(true);
191
-
192
- // Init sdk with your config
193
190
  Api.initSdk(appId, appKey, apiKey, region, baseUrl, listCert, cordova.getActivity().getApplicationContext());
194
-
195
191
  Api.startContext(cordova.getActivity().getApplicationContext(), config);
196
192
 
197
193
  callbackContext.success();
@@ -201,35 +197,8 @@ public class AppICEPlugin extends CordovaPlugin {
201
197
  }
202
198
  }
203
199
 
204
- @CordovaMethod
205
- private void setUserId(JSONArray data, CallbackContext callbackContext){
206
- ArrayList<String> userIdList = new ArrayList<>();
207
- try {
208
- JSONObject object = data.getJSONObject(0) ;
209
- JSONArray arr = object.optJSONArray("userID");
210
- if (arr != null) {
211
- for (int i = 0; i < arr.length(); i++) {
212
- userIdList.add((String) arr.get(i));
213
- }
214
-
215
- if (userIdList != null) {
216
- try {
217
- String[] userIds = userIdList.toArray(new String[userIdList.size()]);
218
- ContextSdk.setUser(userIds, cordova.getActivity().getApplicationContext());
219
- callbackContext.success();
220
- } catch (Throwable e) {
221
- callbackContext.error(e.getMessage());
222
- }
223
- }
224
- }
225
- } catch (Throwable e) {
226
- callbackContext.error(e.getMessage());
227
- }
228
- }
229
-
230
200
  @CordovaMethod
231
201
  private void stopContext(JSONArray data, CallbackContext callbackContext) {
232
- // Stop sdk
233
202
  try {
234
203
  Api.stopContext(cordova.getActivity().getApplicationContext());
235
204
  callbackContext.success();
@@ -239,60 +208,34 @@ public class AppICEPlugin extends CordovaPlugin {
239
208
  }
240
209
 
241
210
  @CordovaMethod
242
- private void isSemusiSensing(JSONArray data, CallbackContext callbackContext) {
243
- // Check whether appice sdk is running or not
244
- try {
245
- boolean key = ContextSdk.isSemusiSensing(cordova.getActivity().getApplicationContext());
246
- if (key)
247
- callbackContext.success(1);
248
- else
249
- callbackContext.success(0);
250
- } catch (Throwable e) {
251
- callbackContext.error(e.getMessage());
252
- }
253
- }
254
-
255
- @CordovaMethod
256
- private void setAsTestDevice(JSONArray data, CallbackContext callbackContext) {
257
- // Set current device is marked as test device
211
+ private void registerLifeCycle(JSONArray data, CallbackContext callbackContext) {
258
212
  try {
259
- ContextSdk.setAsTestDevice(true, cordova.getActivity().getApplicationContext());
260
- callbackContext.success();
261
- } catch (Throwable e) {
262
- callbackContext.error(e.getMessage());
263
- }
264
- }
213
+ // Get a handler that can be used to post to the main thread
214
+ Handler mainHandler = new Handler(Looper.getMainLooper());
265
215
 
266
- @CordovaMethod
267
- private void removeAsTestDevice(JSONArray data, CallbackContext callbackContext) {
268
- // Remove current device is marked as test device
269
- try {
270
- ContextSdk.setAsTestDevice(false, cordova.getActivity().getApplicationContext());
271
- callbackContext.success();
272
- } catch (Throwable e) {
273
- callbackContext.error(e.getMessage());
274
- }
275
- }
216
+ Runnable myRunnable = new Runnable() {
217
+ @Override
218
+ public void run() {
219
+ System.out.println("registerLifeCycle reached");
220
+ ContextSdk.registerLifeCycle(cordova.getActivity().getApplicationContext());
221
+ callbackContext.success();
222
+ }
223
+ };
224
+ mainHandler.post(myRunnable);
276
225
 
277
- @CordovaMethod
278
- private void getIsTestDevice(JSONArray data, CallbackContext callbackContext) {
279
- // Check whether current device is marked as test device
280
- try {
281
- boolean key = ContextSdk.getIsTestDevice(cordova.getActivity().getApplicationContext());
282
- if (key)
283
- callbackContext.success(1);
284
- else
285
- callbackContext.success(0);
286
- } catch (Throwable e) {
287
- callbackContext.error(e.getMessage());
226
+ }catch (Throwable t){
227
+ callbackContext.error(t.getMessage());
288
228
  }
289
229
  }
290
230
 
231
+ /*=================================
232
+ // GET SDK DETAILS
233
+ //================================ */
291
234
  @CordovaMethod
292
- private void openPlayServiceUpdate(JSONArray data, CallbackContext callbackContext) {
293
- // Open up google play service udpate UI for user
235
+ private void getCurrentContext(JSONArray data, CallbackContext callbackContext) {
236
+ // Get user current context from system
294
237
  try {
295
- ContextSdk.openPlayServiceUpdate(cordova.getActivity().getApplicationContext());
238
+ ContextData userData = new ContextSdk(cordova.getActivity().getApplicationContext()).getCurrentContext();
296
239
  callbackContext.success();
297
240
  } catch (Throwable e) {
298
241
  callbackContext.error(e.getMessage());
@@ -321,6 +264,9 @@ public class AppICEPlugin extends CordovaPlugin {
321
264
  }
322
265
  }
323
266
 
267
+ /*======================================
268
+ // DEVICE SETTING APIS
269
+ //=====================================*/
324
270
  @CordovaMethod
325
271
  private void setDeviceId(JSONArray data, CallbackContext callbackContext) {
326
272
  // Set new deviceId in system
@@ -357,6 +303,9 @@ public class AppICEPlugin extends CordovaPlugin {
357
303
  }
358
304
  }
359
305
 
306
+ /*=============================
307
+ // META DATA SETTING APIS
308
+ //=============================*/
360
309
  @CordovaMethod
361
310
  private void getAppKey(JSONArray data, CallbackContext callbackContext) {
362
311
  // Gather existing app-key from system
@@ -390,17 +339,9 @@ public class AppICEPlugin extends CordovaPlugin {
390
339
  }
391
340
  }
392
341
 
393
- @CordovaMethod
394
- private void getCurrentContext(JSONArray data, CallbackContext callbackContext) {
395
- // Get user current context from system
396
- try {
397
- ContextData userData = new ContextSdk(cordova.getActivity().getApplicationContext()).getCurrentContext();
398
- callbackContext.success();
399
- } catch (Throwable e) {
400
- callbackContext.error(e.getMessage());
401
- }
402
- }
403
-
342
+ //=================================
343
+ // ALIAS SETTING APIS
344
+ //==================================
404
345
  @CordovaMethod
405
346
  private void setAlias(JSONArray data, CallbackContext callbackContext) {
406
347
  // Set new deviceId in system
@@ -426,6 +367,35 @@ public class AppICEPlugin extends CordovaPlugin {
426
367
  }
427
368
  }
428
369
 
370
+ //================================
371
+ // USER PROFILE SETTING APIS
372
+ //================================
373
+ @CordovaMethod
374
+ private void setUserId(JSONArray data, CallbackContext callbackContext) {
375
+ ArrayList<String> userIdList = new ArrayList<>();
376
+ try {
377
+ JSONObject object = data.getJSONObject(0);
378
+ JSONArray arr = object.optJSONArray("userID");
379
+ if (arr != null) {
380
+ for (int i = 0; i < arr.length(); i++) {
381
+ userIdList.add((String) arr.get(i));
382
+ }
383
+
384
+ if (userIdList != null) {
385
+ try {
386
+ String[] userIds = userIdList.toArray(new String[userIdList.size()]);
387
+ ContextSdk.setUser(userIds, cordova.getActivity().getApplicationContext());
388
+ callbackContext.success();
389
+ } catch (Throwable e) {
390
+ callbackContext.error(e.getMessage());
391
+ }
392
+ }
393
+ }
394
+ } catch (Throwable e) {
395
+ callbackContext.error(e.getMessage());
396
+ }
397
+ }
398
+
429
399
  @CordovaMethod
430
400
  private void setUser(JSONArray data, CallbackContext callbackContext) {
431
401
  // Set user in system
@@ -463,128 +433,9 @@ public class AppICEPlugin extends CordovaPlugin {
463
433
  }
464
434
  }
465
435
 
466
- @CordovaMethod
467
- private void setChildId(JSONArray data, CallbackContext callbackContext) {
468
- // Set new child-id in system
469
- try {
470
- String childID = (String) data.getJSONObject(0).get("childID");
471
- if (childID != null && childID.length() > 0) {
472
- ContextSdk.setChildId(childID, cordova.getActivity().getApplicationContext());
473
- callbackContext.success();
474
- }
475
- } catch (Throwable e) {
476
- callbackContext.error(e.getMessage());
477
- }
478
- }
479
-
480
- @CordovaMethod
481
- private void getChildId(JSONArray data, CallbackContext callbackContext) {
482
- // Get child-id value from system
483
- try {
484
- String key = ContextSdk.getChildId(cordova.getActivity().getApplicationContext());
485
- callbackContext.success(key);
486
- } catch (Throwable e) {
487
- callbackContext.error(e.getMessage());
488
- }
489
- }
490
-
491
- @CordovaMethod
492
- private void setReferrer(JSONArray data, CallbackContext callbackContext) {
493
- // Set new referrer in system
494
- try {
495
- String key = (String) data.getJSONObject(0).get("referrer");
496
- if (key != null && key.length() > 0) {
497
- ContextSdk.setReferrer(key, cordova.getActivity().getApplicationContext());
498
- callbackContext.success();
499
- }
500
- } catch (Throwable e) {
501
- callbackContext.error(e.getMessage());
502
- }
503
- }
504
-
505
- @CordovaMethod
506
- private void getReferrer(JSONArray data, CallbackContext callbackContext) {
507
- // Get referrer value from system
508
- try {
509
- String key = ContextSdk.getReferrer(cordova.getActivity().getApplicationContext());
510
- callbackContext.success(key);
511
- } catch (Throwable e) {
512
- callbackContext.error(e.getMessage());
513
- }
514
- }
515
-
516
- @CordovaMethod
517
- private void setInstallReferrer(JSONArray data, CallbackContext callbackContext) {
518
- // Set new install referrer in system
519
- try {
520
- String key = (String) data.getJSONObject(0).get("installRef");
521
- if (key != null && key.length() > 0) {
522
- ContextSdk.setInstallReferrer(key, cordova.getActivity().getApplicationContext());
523
- callbackContext.success();
524
- }
525
- } catch (Throwable e) {
526
- callbackContext.error(e.getMessage());
527
- }
528
- }
529
-
530
- @CordovaMethod
531
- private void getInstallReferrer(JSONArray data, CallbackContext callbackContext) {
532
- // Get install referrer value from system
533
- try {
534
- String key = ContextSdk.getInstallReferrer(cordova.getActivity().getApplicationContext());
535
- callbackContext.success(key);
536
- } catch (Throwable e) {
537
- callbackContext.error(e.getMessage());
538
- }
539
- }
540
-
541
- @CordovaMethod
542
- private void setInstaller(JSONArray data, CallbackContext callbackContext) {
543
- // Set new installer in system
544
- try {
545
- String key = (String) data.getJSONObject(0).get("installer");
546
- if (key != null && key.length() > 0) {
547
- ContextSdk.setInstaller(key, cordova.getActivity().getApplicationContext());
548
- callbackContext.success();
549
- }
550
- } catch (Throwable e) {
551
- callbackContext.error(e.getMessage());
552
- }
553
- }
554
-
555
- @CordovaMethod
556
- private void getInstaller(JSONArray data, CallbackContext callbackContext) {
557
- // Get installer value from system
558
- try {
559
- String key = ContextSdk.getInstaller(cordova.getActivity().getApplicationContext());
560
- callbackContext.success(key);
561
- } catch (Throwable e) {
562
- callbackContext.error(e.getMessage());
563
- }
564
- }
565
-
566
- @CordovaMethod
567
- private void getGCMSenderId(JSONArray data, CallbackContext callbackContext) {
568
- // Get gcm sender id
569
- try {
570
- String key = "GCM-Deprecated";
571
- callbackContext.success(key);
572
- } catch (Throwable e) {
573
- callbackContext.error(e.getMessage());
574
- }
575
- }
576
-
577
- @CordovaMethod
578
- private void getDeviceToken(JSONArray data, CallbackContext callbackContext) {
579
- // Get gcm sender id
580
- try {
581
- String registrationId = "";
582
- callbackContext.success(registrationId);
583
- } catch (Throwable e) {
584
- callbackContext.error(e.getMessage());
585
- }
586
- }
587
-
436
+ //=========================================
437
+ // CUSTOM VARIABLE AND EVENT SETTING APIS
438
+ //==========================================
588
439
  @CordovaMethod
589
440
  private void setCustomVariable(JSONArray data, CallbackContext callbackContext) {
590
441
  // Set custom variable in system
@@ -654,6 +505,7 @@ public class AppICEPlugin extends CordovaPlugin {
654
505
  }
655
506
  }
656
507
  } catch (Throwable e) {
508
+ Log.e(TAG, "tagEvent: error ", e);
657
509
  }
658
510
 
659
511
  ContextSdk.tagEventObj(key, mapData, cordova.getActivity().getApplicationContext());
@@ -664,6 +516,52 @@ public class AppICEPlugin extends CordovaPlugin {
664
516
  }
665
517
  }
666
518
 
519
+ //=========================================
520
+ // CHILD KEY SETTING APIS
521
+ //==========================================
522
+
523
+ @CordovaMethod
524
+ private void setChildId(JSONArray data, CallbackContext callbackContext) {
525
+ // Set new child-id in system
526
+ try {
527
+ String childID = (String) data.getJSONObject(0).get("childID");
528
+ if (childID != null && childID.length() > 0) {
529
+ ContextSdk.setChildId(childID, cordova.getActivity().getApplicationContext());
530
+ callbackContext.success();
531
+ }
532
+ } catch (Throwable e) {
533
+ callbackContext.error(e.getMessage());
534
+ }
535
+ }
536
+
537
+ @CordovaMethod
538
+ private void getChildId(JSONArray data, CallbackContext callbackContext) {
539
+ // Get child-id value from system
540
+ try {
541
+ String key = ContextSdk.getChildId(cordova.getActivity().getApplicationContext());
542
+ callbackContext.success(key);
543
+ } catch (Throwable e) {
544
+ callbackContext.error(e.getMessage());
545
+ }
546
+ }
547
+
548
+ //=========================================
549
+ // PLAY STORE SETTING APIS
550
+ //=========================================
551
+ @CordovaMethod
552
+ private void openPlayServiceUpdate(JSONArray data, CallbackContext callbackContext) {
553
+ // Open up google play service update UI for user
554
+ try {
555
+ ContextSdk.openPlayServiceUpdate(cordova.getActivity().getApplicationContext());
556
+ callbackContext.success();
557
+ } catch (Throwable e) {
558
+ callbackContext.error(e.getMessage());
559
+ }
560
+ }
561
+
562
+ //==================================
563
+ // PUSH NOTIFICATION SETTING APIS
564
+ //==================================
667
565
  @CordovaMethod
668
566
  private void setSmallIcon(JSONArray data, CallbackContext callbackContext) {
669
567
  // Set small icon in system
@@ -679,192 +577,87 @@ public class AppICEPlugin extends CordovaPlugin {
679
577
  }
680
578
 
681
579
  @CordovaMethod
682
- private void setSessionTimeout(JSONArray data, CallbackContext callbackContext) {
683
- // Set session timeout in system
580
+ private void getDeviceToken(JSONArray data, CallbackContext callbackContext) {
581
+ // Get gcm sender id
684
582
  try {
685
- int key = data.getJSONObject(0).getInt("timeout");
686
- ContextSdk.setSessionTimeout(key, cordova.getActivity().getApplicationContext());
687
-
688
- callbackContext.success();
583
+ String registrationId = "";
584
+ callbackContext.success(registrationId);
689
585
  } catch (Throwable e) {
690
586
  callbackContext.error(e.getMessage());
691
587
  }
692
588
  }
693
589
 
694
590
  @CordovaMethod
695
- private void getSessionTimeout(JSONArray data, CallbackContext callbackContext) {
696
- // Get installer value from system
591
+ private void onNotificationOpen(JSONArray data, final CallbackContext callbackContext) {
697
592
  try {
698
- int key = ContextSdk.getSessionTimeout(cordova.getActivity().getApplicationContext());
699
- callbackContext.success(key);
593
+ this.callbackContext = callbackContext;
700
594
  } catch (Throwable e) {
701
- callbackContext.error(e.getMessage());
595
+ Log.e(TAG, "onNotificationOpen: error ", e);
702
596
  }
703
597
  }
704
598
 
705
599
  @CordovaMethod
706
- private void trackTouches(JSONArray data, CallbackContext callbackContext) {
600
+ private void pushNotificationClicked(JSONArray data, final CallbackContext callbackContext){
707
601
  try {
708
- DisplayMetrics dm = new DisplayMetrics();
709
- cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
710
- int screenWidth = dm.widthPixels;
711
- int screenHeight = dm.heightPixels;
712
-
713
- JSONObject root = data.getJSONObject(0);
714
- if (root != null) {
715
- double webWidth = (double) root.optInt("w");
716
- double webHeight = (double) root.optInt("h");
717
-
718
- double wRatio = (screenWidth / webWidth);
719
- double hRatio = (screenHeight / webHeight);
720
-
721
- // store rescaled x-y co-ordinates of touch
722
- double x = root.optDouble("x");
723
- double y = root.optDouble("y");
724
- x = x * wRatio;
725
- y = y * hRatio;
726
- root.put("x", x);
727
- root.put("y", y);
728
-
729
- // store rescaled px-py-pw-ph co-ordinates of touch
730
- double px = root.optDouble("px");
731
- double py = root.optDouble("py");
732
- double pw = root.optDouble("pw");
733
- double ph = root.optDouble("ph");
734
- px = px * wRatio;
735
- py = py * hRatio;
736
- pw = pw * wRatio;
737
- ph = ph * hRatio;
738
- root.put("px", px);
739
- root.put("py", py);
740
- root.put("pw", pw);
741
- root.put("ph", ph);
742
-
743
- // re-store rescaled x-y-w-h co-ordinates of input fld
744
- JSONArray newObjects = new JSONArray();
745
- JSONArray objects = root.optJSONArray("arr");
746
- if (objects != null && objects.length() > 0) {
747
- for (int i = 0; i < objects.length(); i++) {
748
- JSONObject inputFld = objects.optJSONObject(i);
749
- if (inputFld != null && inputFld.length() > 0) {
750
- JSONObject obj = new JSONObject(inputFld.toString());
751
- obj.put("x", inputFld.optDouble("x") * wRatio);
752
- obj.put("y", (inputFld.optDouble("y") * hRatio) + inputFld.optDouble("h"));
753
- obj.put("w", inputFld.optDouble("w") * wRatio);
754
- obj.put("h", inputFld.optDouble("h") * hRatio);
755
- newObjects.put(obj);
756
- }
757
- }
758
- }
759
- root.put("arr", newObjects);
602
+ if(data != null){
603
+ String payload = (String) data.getJSONObject(0).get("pushPayload");
604
+ ContextSdk.pushNotificationClicked(payload, cordova.getActivity().getApplicationContext());
605
+ callbackContext.success();
760
606
  }
761
-
762
- View rootView = cordova.getActivity().getWindow().getDecorView().getRootView();
763
- ContextSdk.trackTouches(root, cordova.getActivity().getApplicationContext(), rootView, cordova.getActivity());
764
-
765
- callbackContext.success();
766
607
  } catch (Throwable e) {
767
608
  callbackContext.error(e.getMessage());
609
+ Log.e(TAG, "pushNotificationClicked: error ", e);
768
610
  }
769
611
  }
770
612
 
771
613
  @CordovaMethod
772
- private void trackSwipes(JSONArray data, CallbackContext callbackContext) {
614
+ private void getDeepLinkURL(JSONArray data, final CallbackContext callbackContext){
773
615
  try {
774
- DisplayMetrics dm = new DisplayMetrics();
775
- cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
776
- int screenWidth = dm.widthPixels;
777
- int screenHeight = dm.heightPixels;
778
-
779
- JSONObject root = data.getJSONObject(0);
780
- if (root != null) {
781
- double webWidth = (double) root.optInt("w");
782
- double webHeight = (double) root.optInt("h");
783
-
784
- double wRatio = (screenWidth / webWidth);
785
- double hRatio = (screenHeight / webHeight);
786
-
787
- // store rescaled x-y co-ordinates of touch
788
- double x1 = root.optDouble("x1");
789
- double y1 = root.optDouble("y1");
790
- x1 = x1 * wRatio;
791
- y1 = y1 * hRatio;
792
- root.put("x1", x1);
793
- root.put("y1", y1);
794
-
795
- // store rescaled x-y co-ordinates of touch
796
- double x2 = root.optDouble("x2");
797
- double y2 = root.optDouble("y2");
798
- x2 = x2 * wRatio;
799
- y2 = y2 * hRatio;
800
- root.put("x2", x2);
801
- root.put("y2", y2);
802
-
803
- // re-store rescaled x-y-w-h co-ordinates of input fld
804
- JSONArray newObjects = new JSONArray();
805
- JSONArray objects = root.optJSONArray("arr");
806
- if (objects != null && objects.length() > 0) {
807
- for (int i = 0; i < objects.length(); i++) {
808
- JSONObject inputFld = objects.optJSONObject(i);
809
- if (inputFld != null && inputFld.length() > 0) {
810
- JSONObject obj = new JSONObject(inputFld.toString());
811
- obj.put("x", inputFld.optDouble("x") * wRatio);
812
- obj.put("y", (inputFld.optDouble("y") * hRatio) + inputFld.optDouble("h"));
813
- obj.put("w", inputFld.optDouble("w") * wRatio);
814
- obj.put("h", inputFld.optDouble("h") * hRatio);
815
- newObjects.put(obj);
816
- }
817
- }
616
+ if(data != null){
617
+ String url = "";
618
+ String payload = (String) data.getJSONObject(0).get("pushPayload");
619
+ JSONObject object = new JSONObject(payload);
620
+ url = object.optString("eurl");
621
+ if (object.has("cdata")) {
622
+ JSONObject cDATA = object.optJSONObject("cdata");
623
+ url = cDATA.optString("eurl");
818
624
  }
819
- root.put("arr", newObjects);
625
+ callbackContext.success(url);
820
626
  }
821
-
822
- View rootView = cordova.getActivity().getWindow().getDecorView().getRootView();
823
- ContextSdk.trackSwipes(root, cordova.getActivity().getApplicationContext(), rootView, cordova.getActivity());
824
-
825
- callbackContext.success();
826
627
  } catch (Throwable e) {
827
628
  callbackContext.error(e.getMessage());
629
+ Log.e(TAG, "pushNotificationClicked: error ", e);
828
630
  }
829
631
  }
830
632
 
831
- @CordovaMethod
832
- private void trackScreens(JSONArray data, CallbackContext callbackContext) {
833
- try {
834
- DisplayMetrics dm = new DisplayMetrics();
835
- cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
836
- int screenWidth = dm.widthPixels;
837
- int screenHeight = dm.heightPixels;
838
-
839
- JSONObject root = data.getJSONObject(0);
840
- if (root != null) {
841
- double webWidth = (double) root.optInt("w");
842
- double webHeight = (double) root.optInt("h");
843
-
844
- double wRatio = (screenWidth / webWidth);
845
- double hRatio = (screenHeight / webHeight);
846
-
847
- // re-store rescaled x-y-w-h co-ordinates of input fld
848
- JSONArray newObjects = new JSONArray();
849
- JSONArray objects = root.optJSONArray("arr");
850
- if (objects != null && objects.length() > 0) {
851
- for (int i = 0; i < objects.length(); i++) {
852
- JSONObject inputFld = objects.optJSONObject(i);
853
- if (inputFld != null && inputFld.length() > 0) {
854
- JSONObject obj = new JSONObject(inputFld.toString());
855
- obj.put("x", inputFld.optDouble("x") * wRatio);
856
- obj.put("y", (inputFld.optDouble("y") * hRatio) + inputFld.optDouble("h"));
857
- obj.put("w", inputFld.optDouble("w") * wRatio);
858
- obj.put("h", inputFld.optDouble("h") * hRatio);
859
- newObjects.put(obj);
860
- }
633
+ public static void sendNotification(JSONObject bundle, Context context) {
634
+ new Thread(new Runnable() {
635
+ @Override
636
+ public void run() {
637
+ try {
638
+ System.out.println("testing send notification "+bundle);
639
+ if (callbackContext != null) {
640
+ String pushPaylaod = bundle.getString("ai_content");
641
+ PluginResult result = new PluginResult(PluginResult.Status.OK, pushPaylaod);
642
+ result.setKeepCallback(true);
643
+ callbackContext.sendPluginResult(result);
861
644
  }
645
+ } catch (Throwable t) {
646
+ Log.e(TAG, "run: error ", t);
862
647
  }
863
- root.put("arr", newObjects);
864
648
  }
649
+ }).start();
650
+ }
865
651
 
866
- View rootView = cordova.getActivity().getWindow().getDecorView().getRootView();
867
- ContextSdk.trackScreens(root, cordova.getActivity().getApplicationContext(), rootView, cordova.getActivity());
652
+ //==================================
653
+ // SESSION SETTING APIS
654
+ //==================================
655
+ @CordovaMethod
656
+ private void setSessionTimeout(JSONArray data, CallbackContext callbackContext) {
657
+ // Set session timeout in system
658
+ try {
659
+ int key = data.getJSONObject(0).getInt("timeout");
660
+ ContextSdk.setSessionTimeout(key, cordova.getActivity().getApplicationContext());
868
661
 
869
662
  callbackContext.success();
870
663
  } catch (Throwable e) {
@@ -872,98 +665,221 @@ public class AppICEPlugin extends CordovaPlugin {
872
665
  }
873
666
  }
874
667
 
875
- @Override
876
- public boolean execute(String action, JSONArray data, CallbackContext callbackId) {
877
- Method method = exportedMethods.get(action);
878
- if (method == null) {
879
- return false;
880
- }
881
-
668
+ @CordovaMethod
669
+ private void getSessionTimeout(JSONArray data, CallbackContext callbackContext) {
670
+ // Get installer value from system
882
671
  try {
883
- Boolean result = (Boolean) method.invoke(this, data, callbackId);
884
- return true;
672
+ int key = ContextSdk.getSessionTimeout(cordova.getActivity().getApplicationContext());
673
+ callbackContext.success(key);
885
674
  } catch (Throwable e) {
886
- return false;
675
+ callbackContext.error(e.getMessage());
887
676
  }
888
677
  }
889
678
 
890
- public static void sendNotification(JSONObject bundle, Context context) {
891
- if (!AppICEPlugin.hasNotificationsCallback() && AppICEPlugin.inBackground()) {
892
- String packageName = context.getPackageName();
893
- if (AppICEPlugin.notificationStack == null) {
894
- AppICEPlugin.notificationStack = new ArrayList<JSONObject>();
895
- }
896
- notificationStack.add(bundle);
897
-
898
- /* start the main activity, if not running */
899
- Intent intent = new Intent("android.intent.action.MAIN");
900
- intent.setComponent(new ComponentName(packageName, packageName + ".MainActivity"));
901
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
902
- intent.putExtra("cdvStartInBackground", true);
903
- context.startActivity(intent);
904
679
 
905
- return;
906
- }
680
+ //===============================
681
+ // VISUAL PLAYBACK SETTING APIS
682
+ //===============================
907
683
 
684
+ @CordovaMethod
685
+ private void isSemusiSensing(JSONArray data, CallbackContext callbackContext) {
908
686
  try {
909
- final CallbackContext callbackContext = AppICEPlugin.notificationCallbackContext;
910
- if (callbackContext != null && bundle != null) {
911
-
912
- PluginResult pluginresult = new PluginResult(PluginResult.Status.OK, bundle);
913
- pluginresult.setKeepCallback(true);
914
- callbackContext.sendPluginResult(pluginresult);
915
-
916
-
917
- } else if (callbackContext == null) {
918
- String packageName = context.getPackageName();
919
- if (AppICEPlugin.notificationStack == null) {
920
- AppICEPlugin.notificationStack = new ArrayList<JSONObject>();
921
- }
922
- notificationStack.add(bundle);
923
- }
687
+ boolean key = ContextSdk.isSemusiSensing(cordova.getActivity().getApplicationContext());
688
+ if (key)
689
+ callbackContext.success(1);
690
+ else
691
+ callbackContext.success(0);
924
692
  } catch (Throwable e) {
693
+ callbackContext.error(e.getMessage());
925
694
  }
926
695
  }
927
696
 
928
- private static boolean inBackground = true;
929
- private static ArrayList<JSONObject> notificationStack = null;
930
- private static CallbackContext notificationCallbackContext;
697
+ @CordovaMethod
698
+ private void trackTouches(JSONArray data, CallbackContext callbackContext) {
699
+ new Thread(new Runnable() {
700
+ @Override
701
+ public void run() {
702
+ try {
703
+ DisplayMetrics dm = new DisplayMetrics();
704
+ cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
705
+ int screenWidth = dm.widthPixels;
706
+ int screenHeight = dm.heightPixels;
707
+
708
+ JSONObject root = data.getJSONObject(0);
709
+ if (root != null) {
710
+ double webWidth = (double) root.optInt("w");
711
+ double webHeight = (double) root.optInt("h");
712
+
713
+ double wRatio = (screenWidth / webWidth);
714
+ double hRatio = (screenHeight / webHeight);
715
+
716
+ // store rescaled x-y co-ordinates of touch
717
+ double x = root.optDouble("x");
718
+ double y = root.optDouble("y");
719
+ x = x * wRatio;
720
+ y = y * hRatio;
721
+ root.put("x", x);
722
+ root.put("y", y);
723
+
724
+ // store rescaled px-py-pw-ph co-ordinates of touch
725
+ double px = root.optDouble("px");
726
+ double py = root.optDouble("py");
727
+ double pw = root.optDouble("pw");
728
+ double ph = root.optDouble("ph");
729
+ px = px * wRatio;
730
+ py = py * hRatio;
731
+ pw = pw * wRatio;
732
+ ph = ph * hRatio;
733
+ root.put("px", px);
734
+ root.put("py", py);
735
+ root.put("pw", pw);
736
+ root.put("ph", ph);
737
+
738
+ // re-store rescaled x-y-w-h co-ordinates of input fld
739
+ JSONArray newObjects = new JSONArray();
740
+ JSONArray objects = root.optJSONArray("arr");
741
+ if (objects != null && objects.length() > 0) {
742
+ for (int i = 0; i < objects.length(); i++) {
743
+ JSONObject inputFld = objects.optJSONObject(i);
744
+ if (inputFld != null && inputFld.length() > 0) {
745
+ JSONObject obj = new JSONObject(inputFld.toString());
746
+ obj.put("x", inputFld.optDouble("x") * wRatio);
747
+ obj.put("y", (inputFld.optDouble("y") * hRatio) + inputFld.optDouble("h"));
748
+ obj.put("w", inputFld.optDouble("w") * wRatio);
749
+ obj.put("h", inputFld.optDouble("h") * hRatio);
750
+ newObjects.put(obj);
751
+ }
752
+ }
753
+ }
754
+ root.put("arr", newObjects);
755
+ }
931
756
 
932
- @Override
933
- public void onPause(boolean multitasking) {
934
- AppICEPlugin.inBackground = true;
935
- }
757
+ View rootView = cordova.getActivity().getWindow().getDecorView().getRootView();
758
+ ContextSdk.trackTouches(root, cordova.getActivity().getApplicationContext(), rootView, cordova.getActivity());
936
759
 
937
- @Override
938
- public void onResume(boolean multitasking) {
939
- AppICEPlugin.inBackground = false;
760
+ callbackContext.success();
761
+ } catch (Throwable e) {
762
+ callbackContext.error(e.getMessage());
763
+ }
764
+ }
765
+ }).start();
940
766
  }
941
767
 
942
- @Override
943
- public void onReset() {
944
- AppICEPlugin.notificationCallbackContext = null;
945
- }
768
+ @CordovaMethod
769
+ private void trackSwipes(JSONArray data, CallbackContext callbackContext) {
770
+ new Thread(new Runnable() {
771
+ @Override
772
+ public void run() {
773
+ try {
774
+ DisplayMetrics dm = new DisplayMetrics();
775
+ cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
776
+ int screenWidth = dm.widthPixels;
777
+ int screenHeight = dm.heightPixels;
778
+
779
+ JSONObject root = data.getJSONObject(0);
780
+ if (root != null) {
781
+ double webWidth = (double) root.optInt("w");
782
+ double webHeight = (double) root.optInt("h");
783
+
784
+ double wRatio = (screenWidth / webWidth);
785
+ double hRatio = (screenHeight / webHeight);
786
+
787
+ // store rescaled x-y co-ordinates of touch
788
+ double x1 = root.optDouble("x1");
789
+ double y1 = root.optDouble("y1");
790
+ x1 = x1 * wRatio;
791
+ y1 = y1 * hRatio;
792
+ root.put("x1", x1);
793
+ root.put("y1", y1);
794
+
795
+ // store rescaled x-y co-ordinates of touch
796
+ double x2 = root.optDouble("x2");
797
+ double y2 = root.optDouble("y2");
798
+ x2 = x2 * wRatio;
799
+ y2 = y2 * hRatio;
800
+ root.put("x2", x2);
801
+ root.put("y2", y2);
802
+
803
+ // re-store rescaled x-y-w-h co-ordinates of input fld
804
+ JSONArray newObjects = new JSONArray();
805
+ JSONArray objects = root.optJSONArray("arr");
806
+ if (objects != null && objects.length() > 0) {
807
+ for (int i = 0; i < objects.length(); i++) {
808
+ JSONObject inputFld = objects.optJSONObject(i);
809
+ if (inputFld != null && inputFld.length() > 0) {
810
+ JSONObject obj = new JSONObject(inputFld.toString());
811
+ obj.put("x", inputFld.optDouble("x") * wRatio);
812
+ obj.put("y", (inputFld.optDouble("y") * hRatio) + inputFld.optDouble("h"));
813
+ obj.put("w", inputFld.optDouble("w") * wRatio);
814
+ obj.put("h", inputFld.optDouble("h") * hRatio);
815
+ newObjects.put(obj);
816
+ }
817
+ }
818
+ }
819
+ root.put("arr", newObjects);
820
+ }
946
821
 
947
- public static boolean inBackground() {
948
- return AppICEPlugin.inBackground;
949
- }
822
+ View rootView = cordova.getActivity().getWindow().getDecorView().getRootView();
823
+ ContextSdk.trackSwipes(root, cordova.getActivity().getApplicationContext(), rootView, cordova.getActivity());
950
824
 
951
- public static boolean hasNotificationsCallback() {
952
- return AppICEPlugin.notificationCallbackContext != null;
825
+ callbackContext.success();
826
+ } catch (Throwable e) {
827
+ callbackContext.error(e.getMessage());
828
+ }
829
+ }
830
+ }).start();
953
831
  }
954
832
 
955
833
  @CordovaMethod
956
- private void onNotificationOpen(JSONArray data, final CallbackContext callbackContext) {
834
+ private void trackScreens(JSONArray data, CallbackContext callbackContext) {
957
835
  try {
958
- AppICEPlugin.notificationCallbackContext = callbackContext;
959
- if (AppICEPlugin.notificationStack != null) {
960
- for (JSONObject bundle : AppICEPlugin.notificationStack) {
961
- AppICEPlugin.sendNotification(bundle, this.cordova.getActivity().getApplicationContext());
836
+ new Thread(new Runnable() {
837
+ @Override
838
+ public void run() {
839
+ try {
840
+ DisplayMetrics dm = new DisplayMetrics();
841
+ cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
842
+ int screenWidth = dm.widthPixels;
843
+ int screenHeight = dm.heightPixels;
844
+
845
+ JSONObject root = data.getJSONObject(0);
846
+ if (root != null) {
847
+ double webWidth = (double) root.optInt("w");
848
+ double webHeight = (double) root.optInt("h");
849
+
850
+ double wRatio = (screenWidth / webWidth);
851
+ double hRatio = (screenHeight / webHeight);
852
+
853
+ // re-store rescaled x-y-w-h co-ordinates of input fld
854
+ JSONArray newObjects = new JSONArray();
855
+ JSONArray objects = root.optJSONArray("arr");
856
+ if (objects != null && objects.length() > 0) {
857
+ for (int i = 0; i < objects.length(); i++) {
858
+ JSONObject inputFld = objects.optJSONObject(i);
859
+ if (inputFld != null && inputFld.length() > 0) {
860
+ JSONObject obj = new JSONObject(inputFld.toString());
861
+ obj.put("x", inputFld.optDouble("x") * wRatio);
862
+ obj.put("y", (inputFld.optDouble("y") * hRatio) + inputFld.optDouble("h"));
863
+ obj.put("w", inputFld.optDouble("w") * wRatio);
864
+ obj.put("h", inputFld.optDouble("h") * hRatio);
865
+ newObjects.put(obj);
866
+ }
867
+ }
868
+ }
869
+ root.put("arr", newObjects);
870
+ }
871
+
872
+ View rootView = cordova.getActivity().getWindow().getDecorView().getRootView();
873
+ ContextSdk.trackScreens(root, cordova.getActivity().getApplicationContext(), rootView, cordova.getActivity());
874
+
875
+ callbackContext.success();
876
+ } catch (Throwable e) {
877
+ Log.e(TAG, "trackScreens run: error ", e );
878
+ }
962
879
  }
963
- AppICEPlugin.notificationStack.clear();
964
- }
880
+ }).start();
965
881
  } catch (Throwable e) {
882
+ callbackContext.error(e.getMessage());
966
883
  }
967
884
  }
968
-
969
885
  }