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