reactnative-plugin-appice 1.7.43 → 1.7.45
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/TransactionalCampaign.js +60 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/appice/react/AppICEUtils.java +85 -98
- package/android/src/main/java/com/appice/react/AppIceReactPluginModule.java +63 -9
- package/android/src/main/java/com/appice/react/CampaignCampsReceiver.java +16 -2
- package/android/src/main/java/com/appice/react/EnumConstants.java +36 -1
- package/android/src/main/java/com/appice/react/StringConstants.java +2 -0
- package/campaign.js +43 -0
- package/index.js +95 -65
- package/ios/AppICEReactEvent.m +27 -2
- package/ios/AppIceReactPlugin.h +9 -1
- package/ios/AppIceReactPlugin.m +218 -60
- package/ios/AppIceReactPlugin.xcworkspace/xcuserdata/artherajesh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/package.json +2 -1
- package/reactnative-plugin-appice.podspec +1 -1
- package/example/android/.gradle/7.3.3/checksums/checksums.lock +0 -0
- package/example/android/.gradle/7.3.3/fileChanges/last-build.bin +0 -0
- package/example/android/.gradle/7.3.3/fileHashes/fileHashes.lock +0 -0
- package/example/android/.gradle/7.3.3/gc.properties +0 -0
- package/example/android/.gradle/vcs-1/gc.properties +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// ===============================
|
|
2
|
+
// TransactionalCampaign
|
|
3
|
+
// ===============================
|
|
4
|
+
const Campaign = require('./campaign');
|
|
5
|
+
|
|
6
|
+
class TransactionalCampaign extends Campaign {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this._data.id = null;
|
|
10
|
+
this._data.p = null;
|
|
11
|
+
this._data.name = null;
|
|
12
|
+
this._data.custom = null;
|
|
13
|
+
this._data.delay = 0;
|
|
14
|
+
this._data.users = [];
|
|
15
|
+
this._data.emails = [];
|
|
16
|
+
this._data.msisdns = [];
|
|
17
|
+
this._data.tokens = [];
|
|
18
|
+
this._data.segment = "";
|
|
19
|
+
this._data.payload = [];
|
|
20
|
+
}
|
|
21
|
+
set setCampId(v) {
|
|
22
|
+
this._data.id = v;
|
|
23
|
+
}
|
|
24
|
+
set setPlatform(v) {
|
|
25
|
+
this._data.p = v;
|
|
26
|
+
}
|
|
27
|
+
set setName(v) {
|
|
28
|
+
this._data.name = v;
|
|
29
|
+
}
|
|
30
|
+
set setCustom(v) {
|
|
31
|
+
this._data.custom = v;
|
|
32
|
+
}
|
|
33
|
+
set setDelay(v) {
|
|
34
|
+
this._data.delay = v;
|
|
35
|
+
}
|
|
36
|
+
set setUsers(v) {
|
|
37
|
+
this._data.users = v;
|
|
38
|
+
}
|
|
39
|
+
set setEmails(v) {
|
|
40
|
+
this._data.emails = v;
|
|
41
|
+
}
|
|
42
|
+
set setMsisdns(v) {
|
|
43
|
+
this._data.msisdns = v;
|
|
44
|
+
}
|
|
45
|
+
set setTokens(v) {
|
|
46
|
+
this._data.tokens = v;
|
|
47
|
+
}
|
|
48
|
+
set setSegment(v) {
|
|
49
|
+
this._data.segment = v;
|
|
50
|
+
}
|
|
51
|
+
addPayload(payloadObj) {
|
|
52
|
+
this._data.payload.push(payloadObj.toJSON());
|
|
53
|
+
}
|
|
54
|
+
toRequestPayload() {
|
|
55
|
+
return JSON.stringify(this._data);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default TransactionalCampaign;
|
|
60
|
+
module.exports = TransactionalCampaign;
|
package/android/build.gradle
CHANGED
|
@@ -97,7 +97,7 @@ dependencies {
|
|
|
97
97
|
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.3.1"
|
|
98
98
|
|
|
99
99
|
//appice
|
|
100
|
-
implementation "appice.io.android:sdk:2.6.
|
|
100
|
+
implementation "appice.io.android:sdk:2.6.44"
|
|
101
101
|
|
|
102
102
|
//glide
|
|
103
103
|
implementation "com.github.bumptech.glide:glide:4.11.0"
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
package com.appice.react;
|
|
2
2
|
|
|
3
|
+
import static com.appice.react.AppIceReactPluginModule.isDeviceReadyFlag;
|
|
4
|
+
import static com.appice.react.AppIceReactPluginModule.pendingEventQueue;
|
|
5
|
+
|
|
3
6
|
import android.content.Context;
|
|
4
7
|
import android.content.Intent;
|
|
5
8
|
import android.os.Bundle;
|
|
@@ -8,7 +11,7 @@ import androidx.annotation.NonNull;
|
|
|
8
11
|
import androidx.annotation.Nullable;
|
|
9
12
|
|
|
10
13
|
import com.facebook.react.bridge.Arguments;
|
|
11
|
-
import com.facebook.react.bridge.
|
|
14
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
15
|
import com.facebook.react.bridge.ReadableArray;
|
|
13
16
|
import com.facebook.react.bridge.ReadableMap;
|
|
14
17
|
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
@@ -17,18 +20,18 @@ import com.facebook.react.bridge.WritableArray;
|
|
|
17
20
|
import com.facebook.react.bridge.WritableMap;
|
|
18
21
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
19
22
|
|
|
20
|
-
import java.util.ArrayDeque;
|
|
21
23
|
import java.util.ArrayList;
|
|
22
|
-
import java.util.
|
|
24
|
+
import java.util.Arrays;
|
|
23
25
|
import java.util.HashMap;
|
|
24
26
|
import java.util.Iterator;
|
|
27
|
+
import java.util.List;
|
|
25
28
|
import java.util.Map;
|
|
26
|
-
import java.util.concurrent.atomic.AtomicBoolean;
|
|
27
29
|
|
|
28
30
|
import org.json.JSONArray;
|
|
29
31
|
import org.json.JSONObject;
|
|
30
32
|
|
|
31
33
|
import semusi.activitysdk.ContextSdk;
|
|
34
|
+
import semusi.context.counthandler.CampaignActionListener;
|
|
32
35
|
import semusi.context.ui.appInbox.AppICEInboxMessage;
|
|
33
36
|
|
|
34
37
|
import semusi.context.utility.Utility;
|
|
@@ -39,8 +42,6 @@ import semusi.ruleengine.pushmanager.NotificationClickHandler;
|
|
|
39
42
|
|
|
40
43
|
public class AppICEUtils {
|
|
41
44
|
private static final String TAG = "AppICEUtils";
|
|
42
|
-
static final Deque<Event> EVENT_QUEUE = new ArrayDeque<>();
|
|
43
|
-
static final AtomicBoolean IS_FLUSHING = new AtomicBoolean(false);
|
|
44
45
|
|
|
45
46
|
static class Event {
|
|
46
47
|
final String name;
|
|
@@ -52,86 +53,29 @@ public class AppICEUtils {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
static void sendEventHelper(String eventName, @Nullable WritableMap params, ReactContext context) {
|
|
56
|
-
if (context == null || !context.hasActiveCatalystInstance()) {
|
|
57
|
-
synchronized (EVENT_QUEUE) {
|
|
58
|
-
WritableMap queued = null;
|
|
59
|
-
if (params != null) {
|
|
60
|
-
try {
|
|
61
|
-
queued = cloneReadableMap(params);
|
|
62
|
-
} catch (Exception ex) {
|
|
63
|
-
printLog(TAG, "sendEvent: failed to clone params for queue " + eventName + " - " + ex.getMessage());
|
|
64
|
-
queued = null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
EVENT_QUEUE.add(new Event(eventName, queued));
|
|
68
|
-
}
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
56
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
emitCopy = null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
83
|
-
.emit(eventName, emitCopy);
|
|
84
|
-
printLog(TAG, "Successfully emitted event: " + eventName);
|
|
85
|
-
} catch (Exception e) {
|
|
86
|
-
printLog(TAG, "emit failed for " + eventName + " - " + e.getMessage());
|
|
87
|
-
synchronized (EVENT_QUEUE) {
|
|
88
|
-
WritableMap queued = null;
|
|
89
|
-
if (params != null) {
|
|
90
|
-
try {
|
|
91
|
-
queued = cloneReadableMap(params);
|
|
92
|
-
} catch (Exception ex) {
|
|
93
|
-
queued = null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
EVENT_QUEUE.add(new Event(eventName, queued));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
static void flushEventQueue(ReactContext reactContext) {
|
|
102
|
-
if (reactContext == null || !reactContext.hasActiveCatalystInstance()) {
|
|
57
|
+
// removed old logic that became overcomplicated with AI. later on when I reworked think
|
|
58
|
+
//of using different approach which flushevent when flag got updated
|
|
59
|
+
protected static void flushEventQueue(ReactApplicationContext ctx) {
|
|
60
|
+
if (!isDeviceReadyFlag || pendingEventQueue.isEmpty()) {
|
|
61
|
+
printLog("ActionPushDebug flushEventQueue", "Nothing to flush. flag=" + isDeviceReadyFlag + " queueSize=" + pendingEventQueue.size());
|
|
103
62
|
return;
|
|
104
63
|
}
|
|
105
64
|
|
|
106
|
-
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
65
|
+
printLog("ActionPushDebug flushEventQueue", "Flushing " + pendingEventQueue.size() + " events");
|
|
109
66
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
toEmit = event.params;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
125
|
-
.emit(event.name, toEmit);
|
|
126
|
-
printLog(TAG, "Successfully flushed event: " + event.name + ". Remaining in queue: " + EVENT_QUEUE.size());
|
|
127
|
-
} catch (Exception e) {
|
|
128
|
-
EVENT_QUEUE.addFirst(event);
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
67
|
+
List<Map<String, Object>> toFlush = new ArrayList<>(pendingEventQueue);
|
|
68
|
+
pendingEventQueue.clear();
|
|
69
|
+
|
|
70
|
+
for (Map<String, Object> event : toFlush) {
|
|
71
|
+
try {
|
|
72
|
+
String eventName = (String) event.get("eventName");
|
|
73
|
+
WritableMap params = (WritableMap) event.get("param");
|
|
74
|
+
ctx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params);
|
|
75
|
+
printLog("ActionPushDebug flushEventQueue", "Flushed: " + eventName);
|
|
76
|
+
} catch (Exception e) {
|
|
77
|
+
printLog("ActionPushDebug flushEventQueue", "Flush failed: " + e.getMessage());
|
|
132
78
|
}
|
|
133
|
-
} finally {
|
|
134
|
-
IS_FLUSHING.set(false);
|
|
135
79
|
}
|
|
136
80
|
}
|
|
137
81
|
|
|
@@ -295,7 +239,6 @@ public class AppICEUtils {
|
|
|
295
239
|
}
|
|
296
240
|
|
|
297
241
|
|
|
298
|
-
|
|
299
242
|
public static WritableMap toWritableMap(Map<String, Object> map) {
|
|
300
243
|
WritableMap writableMap = Arguments.createMap();
|
|
301
244
|
Iterator iterator = map.entrySet().iterator();
|
|
@@ -452,7 +395,7 @@ public class AppICEUtils {
|
|
|
452
395
|
}
|
|
453
396
|
}
|
|
454
397
|
return jsonObject;
|
|
455
|
-
}catch (Throwable t){
|
|
398
|
+
} catch (Throwable t) {
|
|
456
399
|
return null;
|
|
457
400
|
}
|
|
458
401
|
}
|
|
@@ -487,7 +430,7 @@ public class AppICEUtils {
|
|
|
487
430
|
}
|
|
488
431
|
}
|
|
489
432
|
return jsonArray;
|
|
490
|
-
}catch (Throwable t){
|
|
433
|
+
} catch (Throwable t) {
|
|
491
434
|
return null;
|
|
492
435
|
}
|
|
493
436
|
}
|
|
@@ -496,9 +439,10 @@ public class AppICEUtils {
|
|
|
496
439
|
System.out.println(TAG + ", " + message);
|
|
497
440
|
}
|
|
498
441
|
|
|
499
|
-
|
|
442
|
+
|
|
443
|
+
public static boolean handleAppICEPayload(@NonNull Intent intent, Context context) {
|
|
500
444
|
try {
|
|
501
|
-
if (intent.getExtras() != null){
|
|
445
|
+
if (intent.getExtras() != null) {
|
|
502
446
|
Bundle bundle = intent.getExtras();
|
|
503
447
|
boolean isAppICEPush = bundle.getBoolean("ai_push", false);
|
|
504
448
|
if (isAppICEPush) {
|
|
@@ -507,24 +451,24 @@ public class AppICEUtils {
|
|
|
507
451
|
intent.removeExtra("ai_push");
|
|
508
452
|
}
|
|
509
453
|
}
|
|
510
|
-
}catch (Throwable t){
|
|
511
|
-
printLog("PUSH", " exception in click "+t);
|
|
454
|
+
} catch (Throwable t) {
|
|
455
|
+
printLog("PUSH", " exception in click " + t);
|
|
512
456
|
}
|
|
513
457
|
return false;
|
|
514
458
|
}
|
|
515
459
|
|
|
516
460
|
/**
|
|
517
461
|
* Handles app link actions triggered from a notification click.
|
|
518
|
-
*
|
|
462
|
+
* <p>
|
|
519
463
|
* Flow:
|
|
520
464
|
* 1. Extracts NotificationClickHandler from the incoming Intent.
|
|
521
465
|
* 2. Retrieves the payload associated with the notification.
|
|
522
466
|
* 3. Validates the payload before processing.
|
|
523
467
|
* 4. If valid:
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
468
|
+
* - Triggers deep link handling via ContextSdk.handleOpenLinkUrl().
|
|
469
|
+
* - Logs the click event via ContextSdk.pushNotificationClicked().
|
|
470
|
+
* - Clears the intent to prevent duplicate processing.
|
|
471
|
+
* <p>
|
|
528
472
|
* Edge Cases Handled:
|
|
529
473
|
* - Null intent
|
|
530
474
|
* - Missing or invalid NotificationClickHandler
|
|
@@ -536,23 +480,66 @@ public class AppICEUtils {
|
|
|
536
480
|
*/
|
|
537
481
|
public static void handleAppLink(Intent intent, Context context) {
|
|
538
482
|
try {
|
|
539
|
-
if (intent != null){
|
|
483
|
+
if (intent != null) {
|
|
540
484
|
NotificationClickHandler clickHandler = NotificationClickHandler.fromIntent(intent);
|
|
541
485
|
if (clickHandler != null) {
|
|
542
486
|
String payload = clickHandler.getPayload();
|
|
543
|
-
|
|
487
|
+
printLog("handleAppLink","handleAppLink payload " + payload);
|
|
544
488
|
if (Utility.isValidObject(payload)) {
|
|
545
489
|
ContextSdk.handleOpenLinkUrl(payload, context);
|
|
546
490
|
ContextSdk.pushNotificationClicked(payload, context);
|
|
547
491
|
clickHandler.deleteIntent(intent);
|
|
548
492
|
} else
|
|
549
|
-
|
|
493
|
+
printLog("handleAppLink","payload is not valid");
|
|
550
494
|
}
|
|
551
|
-
}else
|
|
552
|
-
|
|
495
|
+
} else
|
|
496
|
+
printLog("handleAppLink","intent is null ");
|
|
553
497
|
} catch (Throwable e) {
|
|
554
|
-
|
|
498
|
+
printLog("handleAppLink","exception in null ");
|
|
555
499
|
}
|
|
556
500
|
}
|
|
557
501
|
|
|
502
|
+
// this function will handle both normal push and action button push.
|
|
503
|
+
// through listner user will identify.
|
|
504
|
+
public static void handleClickOnPush(Intent intent, Context context) {
|
|
505
|
+
try {
|
|
506
|
+
if (intent != null) {
|
|
507
|
+
if (intent.getExtras() != null) {
|
|
508
|
+
Bundle bundle = intent.getExtras();
|
|
509
|
+
boolean isAppICEPush = bundle.getBoolean("ai_push", false);
|
|
510
|
+
if (isAppICEPush) {
|
|
511
|
+
CampaignCampsReceiver campsReceiver = new CampaignCampsReceiver();
|
|
512
|
+
campsReceiver.sendCallback(bundle, context);
|
|
513
|
+
intent.removeExtra("ai_push");
|
|
514
|
+
}else {
|
|
515
|
+
NotificationClickHandler.handleClickCallback(intent, context, new CampaignActionListener() {
|
|
516
|
+
@Override
|
|
517
|
+
public void onActionButtonClicked(Campaign campaign) {
|
|
518
|
+
WritableMap params = Arguments.createMap();
|
|
519
|
+
JSONObject campaignJson = campaign.toJson();
|
|
520
|
+
|
|
521
|
+
if (campaignJson != null && campaignJson.length() > 0) {
|
|
522
|
+
String campaignStr = campaignJson.toString();
|
|
523
|
+
params.putString(EnumConstants.APPICE_PUSH_NOTIFICATION_ACTION_BUTTON_CLICKED.getValue(), campaignStr);
|
|
524
|
+
|
|
525
|
+
printLog("ActionPushDebug onActionButtonClicked", "action button clicked | campaign: " + campaignStr);
|
|
526
|
+
printLog("ActionPushDebug onActionButtonClicked", "isDeviceReadyFlag: " + isDeviceReadyFlag);
|
|
527
|
+
printLog("ActionPushDebug onActionButtonClicked", "queue size before send: " + pendingEventQueue.size());
|
|
528
|
+
|
|
529
|
+
AppIceReactPluginModule.sendEvent(EnumConstants.APPICE_PUSH_NOTIFICATION_ACTION_BUTTON_CLICKED.getValue(), params);
|
|
530
|
+
|
|
531
|
+
printLog("ActionPushDebug onActionButtonClicked", "queue size after send: " + pendingEventQueue.size());
|
|
532
|
+
} else {
|
|
533
|
+
printLog("ActionPushDebug onActionButtonClicked", "campaignJson is null or empty — event NOT sent");
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
} else
|
|
540
|
+
printLog("ActionPushDebug", " | intent is null ");
|
|
541
|
+
} catch (Throwable e) {
|
|
542
|
+
printLog("ActionPushDebug"," | exception in null ");
|
|
543
|
+
}
|
|
544
|
+
}
|
|
558
545
|
}
|
|
@@ -36,6 +36,7 @@ import semusi.model.campaign.TransactionalCampaign;
|
|
|
36
36
|
import semusi.model.user.User;
|
|
37
37
|
|
|
38
38
|
import java.util.*;
|
|
39
|
+
import java.util.concurrent.ConcurrentHashMap;
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
import androidx.annotation.NonNull;
|
|
@@ -45,6 +46,7 @@ import com.facebook.react.bridge.ReadableArray;
|
|
|
45
46
|
import com.facebook.react.bridge.WritableArray;
|
|
46
47
|
import com.facebook.react.bridge.WritableMap;
|
|
47
48
|
import com.facebook.react.module.annotations.ReactModule;
|
|
49
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
48
50
|
|
|
49
51
|
import org.json.JSONObject;
|
|
50
52
|
|
|
@@ -52,6 +54,9 @@ import org.json.JSONObject;
|
|
|
52
54
|
public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
53
55
|
private static ReactApplicationContext context = null;
|
|
54
56
|
public static final String NAME = "AppIceReactPlugin";
|
|
57
|
+
protected static volatile boolean isDeviceReadyFlag;
|
|
58
|
+
protected static final List<Map<String, Object>> pendingEventQueue =
|
|
59
|
+
Collections.synchronizedList(new ArrayList<>());
|
|
55
60
|
|
|
56
61
|
public AppIceReactPluginModule(ReactApplicationContext reactContext) {
|
|
57
62
|
super(reactContext);
|
|
@@ -99,7 +104,8 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
99
104
|
, context);
|
|
100
105
|
|
|
101
106
|
Api.startContext(context, config);
|
|
102
|
-
|
|
107
|
+
String token= ContextSdk.getFCMToken(context);
|
|
108
|
+
printLog("AppICE","| firebase token = "+token);
|
|
103
109
|
} catch (Exception e) {
|
|
104
110
|
printLog(NAME, "Exception in startContext : " + e);
|
|
105
111
|
}
|
|
@@ -639,17 +645,30 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
639
645
|
Context context = getReactApplicationContext();
|
|
640
646
|
callback.invoke(ContextSdk.getInternalId(context));
|
|
641
647
|
}
|
|
642
|
-
|
|
643
|
-
public void
|
|
644
|
-
if (
|
|
645
|
-
|
|
646
|
-
|
|
648
|
+
|
|
649
|
+
public static void sendEvent(String eventName, @Nullable WritableMap params) {
|
|
650
|
+
if (isDeviceReadyFlag) {
|
|
651
|
+
try {
|
|
652
|
+
context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params);
|
|
653
|
+
printLog("ActionPushDebug sendEvent", "Successfully emitted event: " + eventName);
|
|
654
|
+
} catch (Exception e) {
|
|
655
|
+
printLog("ActionPushDebug sendEvent", "emit failed for " + eventName + " - " + e.getMessage());
|
|
656
|
+
}
|
|
657
|
+
} else {
|
|
658
|
+
Map<String, Object> pending = new HashMap<>();
|
|
659
|
+
pending.put("eventName", eventName);
|
|
660
|
+
pending.put("param", params);
|
|
661
|
+
pendingEventQueue.add(pending);
|
|
662
|
+
printLog("ActionPushDebug sendEvent", "Queued event: " + eventName + " Queue size: " + pendingEventQueue.size());
|
|
647
663
|
}
|
|
648
664
|
}
|
|
649
665
|
|
|
650
|
-
|
|
651
|
-
public
|
|
652
|
-
|
|
666
|
+
@ReactMethod
|
|
667
|
+
public void isDeviceReady(Boolean flag) {
|
|
668
|
+
ReactApplicationContext ctx = getReactApplicationContext();
|
|
669
|
+
isDeviceReadyFlag = flag;
|
|
670
|
+
printLog("ActionPushDebug", "isDeviceReadyFlag " + isDeviceReadyFlag);
|
|
671
|
+
flushEventQueue(ctx);
|
|
653
672
|
}
|
|
654
673
|
|
|
655
674
|
private static AppICEInboxMessage getMediaPreProcessing(ReadableMap inboxMessage,Context context) {
|
|
@@ -886,6 +905,35 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
886
905
|
}
|
|
887
906
|
}
|
|
888
907
|
|
|
908
|
+
//======================================================
|
|
909
|
+
// INAPP
|
|
910
|
+
//======================================================
|
|
911
|
+
|
|
912
|
+
@ReactMethod
|
|
913
|
+
public void resumeInApp(){
|
|
914
|
+
Context context = getReactApplicationContext();
|
|
915
|
+
ContextSdk.resumeInApp(context);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
@ReactMethod
|
|
919
|
+
public void suspendInApp(){
|
|
920
|
+
Context context = getReactApplicationContext();
|
|
921
|
+
ContextSdk.suspendInApp(context);
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
@ReactMethod
|
|
925
|
+
public void discardInApp(){
|
|
926
|
+
Context context = getReactApplicationContext();
|
|
927
|
+
ContextSdk.discardInApp(context);
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
@ReactMethod
|
|
931
|
+
public void dismissInApp(){
|
|
932
|
+
ContextSdk.dismissInApp();
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
//================================================================
|
|
936
|
+
|
|
889
937
|
@Nullable
|
|
890
938
|
@Override
|
|
891
939
|
public Map<String, Object> getConstants() {
|
|
@@ -902,7 +950,9 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
902
950
|
constants.put(EnumConstants.APPICE_USER_AGE.getConstants(), EnumConstants.APPICE_USER_AGE.getValue());
|
|
903
951
|
constants.put(EnumConstants.APPICE_USER_GENDER.getConstants(), EnumConstants.APPICE_USER_GENDER.getValue());
|
|
904
952
|
constants.put(EnumConstants.APPICE_PUSH_NOTIFICATION_CLICKED.getConstants(), EnumConstants.APPICE_PUSH_NOTIFICATION_CLICKED.getValue());
|
|
953
|
+
constants.put(EnumConstants.APPICE_PUSH_NOTIFICATION_ACTION_BUTTON_CLICKED.getConstants(), EnumConstants.APPICE_PUSH_NOTIFICATION_ACTION_BUTTON_CLICKED.getValue());
|
|
905
954
|
constants.put(EnumConstants.APPICE_INAPP_NOTIFICATION_CLICKED.getConstants(), EnumConstants.APPICE_INAPP_NOTIFICATION_CLICKED.getValue());
|
|
955
|
+
constants.put(EnumConstants.APPICE_HTML_INAPP_NOTIFICATION_CLICKED.getConstants(), EnumConstants.APPICE_HTML_INAPP_NOTIFICATION_CLICKED.getValue());
|
|
906
956
|
constants.put(EnumConstants.FIRST_SEEN.getConstants(), EnumConstants.FIRST_SEEN.getValue());
|
|
907
957
|
constants.put(EnumConstants.LAST_SEEN.getConstants(), EnumConstants.LAST_SEEN.getValue());
|
|
908
958
|
constants.put(EnumConstants.TOP_N_PRODUCTS_VIEWED.getConstants(), EnumConstants.TOP_N_PRODUCTS_VIEWED.getValue());
|
|
@@ -924,6 +974,10 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
924
974
|
constants.put(EnumConstants.ACTION_URL.getConstants(), EnumConstants.ACTION_URL.getValue());
|
|
925
975
|
constants.put(EnumConstants.ACTION_TYPE.getConstants(), EnumConstants.ACTION_TYPE.getValue());
|
|
926
976
|
constants.put(EnumConstants.CUSTOMDATA.getConstants(), EnumConstants.CUSTOMDATA.getValue());
|
|
977
|
+
constants.put(EnumConstants.ACTION_TYPE_CUSTOM.getConstants(), EnumConstants.ACTION_TYPE_CUSTOM.getValue());
|
|
978
|
+
constants.put(EnumConstants.ACTION_TYPE_DEEPLINK.getConstants(), EnumConstants.ACTION_TYPE_DEEPLINK.getValue());
|
|
979
|
+
constants.put(EnumConstants.ACTION_TYPE_REPLY.getConstants(), EnumConstants.ACTION_TYPE_REPLY.getValue());
|
|
980
|
+
constants.put(EnumConstants.ACTION_TYPE_REMIND_ME_LATER.getConstants(), EnumConstants.ACTION_TYPE_REMIND_ME_LATER.getValue());
|
|
927
981
|
|
|
928
982
|
return constants;
|
|
929
983
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.appice.react;
|
|
2
2
|
|
|
3
|
+
import static com.appice.react.AppICEUtils.printLog;
|
|
4
|
+
|
|
3
5
|
import android.content.BroadcastReceiver;
|
|
4
6
|
import android.content.Context;
|
|
5
7
|
import android.content.Intent;
|
|
@@ -10,6 +12,8 @@ import com.facebook.react.bridge.WritableMap;
|
|
|
10
12
|
|
|
11
13
|
import org.json.JSONObject;
|
|
12
14
|
|
|
15
|
+
import semusi.context.utility.Utility;
|
|
16
|
+
|
|
13
17
|
public class CampaignCampsReceiver extends BroadcastReceiver {
|
|
14
18
|
private static final String TAG = "CampaignCampsReceiver";
|
|
15
19
|
public CampaignCampsReceiver(){
|
|
@@ -20,7 +24,7 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
|
|
|
20
24
|
try {
|
|
21
25
|
sendCallback(intent.getExtras(), context);
|
|
22
26
|
} catch (Exception e) {
|
|
23
|
-
|
|
27
|
+
printLog(TAG,e.getMessage());
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -29,8 +33,11 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
|
|
|
29
33
|
|
|
30
34
|
String cdata = extra.getString("cdata");
|
|
31
35
|
String ai_content = extra.getString("ai_content");
|
|
36
|
+
String campaignStr = extra.getString("campaign");
|
|
32
37
|
boolean category = extra.getBoolean("ai_inapp");
|
|
38
|
+
boolean isHTMLInApp = extra.getBoolean("html_ai_inapp");
|
|
33
39
|
|
|
40
|
+
printLog("inapp flow test |","sendCallback |ai_content "+ai_content+"| category "+category);
|
|
34
41
|
if (category) {
|
|
35
42
|
if (cdata != null && cdata.length() > 0) {
|
|
36
43
|
WritableMap params = Arguments.createMap();
|
|
@@ -38,6 +45,13 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
|
|
|
38
45
|
AppIceReactPluginModule.sendEvent(EnumConstants.APPICE_INAPP_NOTIFICATION_CLICKED.getValue(), params);
|
|
39
46
|
}
|
|
40
47
|
}
|
|
48
|
+
if (isHTMLInApp){
|
|
49
|
+
if (Utility.isValidObject(campaignStr)) {
|
|
50
|
+
WritableMap params = Arguments.createMap();
|
|
51
|
+
params.putString(EnumConstants.APPICE_HTML_INAPP_NOTIFICATION_CLICKED.getValue(), campaignStr);
|
|
52
|
+
AppIceReactPluginModule.sendEvent(EnumConstants.APPICE_HTML_INAPP_NOTIFICATION_CLICKED.getValue(), params);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
41
55
|
|
|
42
56
|
if (ai_content != null && ai_content.length()>0){
|
|
43
57
|
JSONObject pushContent = new JSONObject(ai_content);
|
|
@@ -50,7 +64,7 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
|
|
|
50
64
|
}
|
|
51
65
|
}
|
|
52
66
|
} catch (Exception e) {
|
|
53
|
-
|
|
67
|
+
printLog(TAG,e.getMessage());
|
|
54
68
|
}
|
|
55
69
|
}
|
|
56
70
|
}
|
|
@@ -31,11 +31,13 @@ public enum EnumConstants {
|
|
|
31
31
|
//PUSH
|
|
32
32
|
//============================
|
|
33
33
|
APPICE_PUSH_NOTIFICATION_CLICKED("AppICEPushNotificationClicked"),
|
|
34
|
+
APPICE_PUSH_NOTIFICATION_ACTION_BUTTON_CLICKED("AppICEPushNotificationActionButtonClicked"),
|
|
34
35
|
|
|
35
36
|
//===========================
|
|
36
37
|
//IN-APP
|
|
37
38
|
//============================
|
|
38
39
|
APPICE_INAPP_NOTIFICATION_CLICKED("AppICEInAppClicked"),
|
|
40
|
+
APPICE_HTML_INAPP_NOTIFICATION_CLICKED("AppICEHTMLInAppClicked"),
|
|
39
41
|
|
|
40
42
|
//============================
|
|
41
43
|
//INBOX
|
|
@@ -88,7 +90,16 @@ public enum EnumConstants {
|
|
|
88
90
|
CAMP_ID("CAMP_ID"),
|
|
89
91
|
ACTION_URL("ACTION_URL"),
|
|
90
92
|
ACTION_TYPE("ACTION_TYPE"),
|
|
91
|
-
CUSTOMDATA("CUSTOMDATA")
|
|
93
|
+
CUSTOMDATA("CUSTOMDATA"),
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
//=======================
|
|
97
|
+
// ACTION TYPES
|
|
98
|
+
//=======================
|
|
99
|
+
ACTION_TYPE_CUSTOM("ACTION_TYPE_CUSTOM"),
|
|
100
|
+
ACTION_TYPE_DEEPLINK("ACTION_TYPE_DEEPLINK"),
|
|
101
|
+
ACTION_TYPE_REPLY("ACTION_TYPE_REPLY"),
|
|
102
|
+
ACTION_TYPE_REMIND_ME_LATER("ACTION_TYPE_REMIND_ME_LATER");
|
|
92
103
|
|
|
93
104
|
private String constants;
|
|
94
105
|
|
|
@@ -148,10 +159,18 @@ public enum EnumConstants {
|
|
|
148
159
|
return StringConstants.APPICE_PUSH_NOTIFICATION_CLICKED;
|
|
149
160
|
}
|
|
150
161
|
|
|
162
|
+
case APPICE_PUSH_NOTIFICATION_ACTION_BUTTON_CLICKED:{
|
|
163
|
+
return StringConstants.APPICE_PUSH_NOTIFICATION_ACTION_BUTTON_CLICKED;
|
|
164
|
+
}
|
|
165
|
+
|
|
151
166
|
case APPICE_INAPP_NOTIFICATION_CLICKED:{
|
|
152
167
|
return StringConstants.APPICE_INAPP_NOTIFICATION_CLICKED;
|
|
153
168
|
}
|
|
154
169
|
|
|
170
|
+
case APPICE_HTML_INAPP_NOTIFICATION_CLICKED:{
|
|
171
|
+
return StringConstants.APPICE_HTML_INAPP_NOTIFICATION_CLICKED;
|
|
172
|
+
}
|
|
173
|
+
|
|
155
174
|
case INBOX_MESSAGE:{
|
|
156
175
|
return StringConstants.INBOX_MESSAGE;
|
|
157
176
|
}
|
|
@@ -272,6 +291,22 @@ public enum EnumConstants {
|
|
|
272
291
|
case CUSTOMDATA:{
|
|
273
292
|
return CUSTOM_DATA;
|
|
274
293
|
}
|
|
294
|
+
|
|
295
|
+
case ACTION_TYPE_CUSTOM:{
|
|
296
|
+
return CampaignConstants.CUSTOM;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
case ACTION_TYPE_DEEPLINK:{
|
|
300
|
+
return CampaignConstants.DEEP_LINK;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
case ACTION_TYPE_REPLY:{
|
|
304
|
+
return CampaignConstants.REPLY;
|
|
305
|
+
}
|
|
306
|
+
case ACTION_TYPE_REMIND_ME_LATER:{
|
|
307
|
+
return CampaignConstants.REMIND_LATER;
|
|
308
|
+
}
|
|
309
|
+
|
|
275
310
|
default:
|
|
276
311
|
return "";
|
|
277
312
|
}
|
|
@@ -8,7 +8,9 @@ public interface StringConstants{
|
|
|
8
8
|
String MEDIA_THUMBNAIL = "mediaThumbnail";
|
|
9
9
|
String MEDIA_DATA = "mediaData";
|
|
10
10
|
String APPICE_PUSH_NOTIFICATION_CLICKED = "AppICEPushNotificationClicked";
|
|
11
|
+
String APPICE_PUSH_NOTIFICATION_ACTION_BUTTON_CLICKED = "AppICEPushNotificationActionButtonClicked";
|
|
11
12
|
String APPICE_INAPP_NOTIFICATION_CLICKED = "AppICEInAppClicked";
|
|
13
|
+
String APPICE_HTML_INAPP_NOTIFICATION_CLICKED = "AppICEHTMLInAppClicked";
|
|
12
14
|
String INBOX_MESSAGE = "message";
|
|
13
15
|
String INBOX_TITLE = "title";
|
|
14
16
|
String INBOX_MESSAGE_STATUS = "messageStatus";
|