reactnative-plugin-appice 1.7.45 → 1.7.47
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/android/src/main/java/com/appice/react/AppICEUtils.java +118 -33
- package/android/src/main/java/com/appice/react/CampaignCampsReceiver.java +4 -0
- package/android/src/main/java/com/appice/react/EnumConstants.java +10 -0
- package/android/src/main/java/com/appice/react/StringConstants.java +2 -0
- package/ios/AppIceReactPlugin.m +6 -1
- package/package.json +1 -1
- package/reactnative-plugin-appice.podspec +1 -1
|
@@ -25,6 +25,7 @@ import java.util.Arrays;
|
|
|
25
25
|
import java.util.HashMap;
|
|
26
26
|
import java.util.Iterator;
|
|
27
27
|
import java.util.List;
|
|
28
|
+
import java.util.Locale;
|
|
28
29
|
import java.util.Map;
|
|
29
30
|
|
|
30
31
|
import org.json.JSONArray;
|
|
@@ -35,6 +36,7 @@ import semusi.context.counthandler.CampaignActionListener;
|
|
|
35
36
|
import semusi.context.ui.appInbox.AppICEInboxMessage;
|
|
36
37
|
|
|
37
38
|
import semusi.context.utility.Utility;
|
|
39
|
+
import semusi.model.campaign.Action;
|
|
38
40
|
import semusi.model.campaign.Campaign;
|
|
39
41
|
import semusi.model.user.User;
|
|
40
42
|
import semusi.ruleengine.pushmanager.NotificationClickHandler;
|
|
@@ -54,8 +56,6 @@ public class AppICEUtils {
|
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
|
|
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
59
|
protected static void flushEventQueue(ReactApplicationContext ctx) {
|
|
60
60
|
if (!isDeviceReadyFlag || pendingEventQueue.isEmpty()) {
|
|
61
61
|
printLog("ActionPushDebug flushEventQueue", "Nothing to flush. flag=" + isDeviceReadyFlag + " queueSize=" + pendingEventQueue.size());
|
|
@@ -170,8 +170,22 @@ public class AppICEUtils {
|
|
|
170
170
|
inboxObject.putString(EnumConstants.INBOX_MESSAGE.getValue(), inboxMessage.getMessageBody());
|
|
171
171
|
inboxObject.putString(EnumConstants.INBOX_MESSAGE_ICON.getValue(), inboxMessage.getMessageIcon());
|
|
172
172
|
inboxObject.putMap(EnumConstants.INBOX_CUSTOM_DATA.getValue(), toWritableMap(inboxMessage.getCustomData()));
|
|
173
|
+
inboxObject.putString(EnumConstants.INBOX_EXPANDED_IMAGE.getValue(), inboxMessage.getExpandedImage());
|
|
174
|
+
List<Action> actionList = inboxMessage.getActions();
|
|
175
|
+
if (actionList !=null && !actionList.isEmpty()){
|
|
176
|
+
ArrayList<String> actionArray = new ArrayList<>();
|
|
177
|
+
for (int i = 0; i < actionList.size(); i++) {
|
|
178
|
+
Action action = actionList.get(i);
|
|
179
|
+
if (action !=null) {
|
|
180
|
+
actionArray.add(action.toJson().toString());
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
WritableArray writableArray = toWritableArray(actionArray);
|
|
184
|
+
inboxObject.putArray(EnumConstants.INBOX_ACTIONS.getValue(), writableArray);
|
|
185
|
+
}
|
|
173
186
|
}
|
|
174
187
|
} catch (Throwable throwable) {
|
|
188
|
+
Utility.loginfo("exception in convertClassToWritableMap "+throwable);
|
|
175
189
|
}
|
|
176
190
|
return inboxObject;
|
|
177
191
|
}
|
|
@@ -499,42 +513,28 @@ public class AppICEUtils {
|
|
|
499
513
|
}
|
|
500
514
|
}
|
|
501
515
|
|
|
502
|
-
// this function will handle both normal push and action button push.
|
|
503
|
-
// through listner user will identify.
|
|
504
516
|
public static void handleClickOnPush(Intent intent, Context context) {
|
|
505
517
|
try {
|
|
506
518
|
if (intent != null) {
|
|
507
519
|
if (intent.getExtras() != null) {
|
|
508
520
|
Bundle bundle = intent.getExtras();
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
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
|
-
}
|
|
521
|
+
if (bundle != null) {
|
|
522
|
+
|
|
523
|
+
NotificationClickHandler pushClickData = NotificationClickHandler.fromBundle(bundle);
|
|
524
|
+
String payload = pushClickData.getPayload();
|
|
525
|
+
|
|
526
|
+
int pos = bundle.getInt("pos", -1);
|
|
527
|
+
int notificationId = bundle.getInt("n", 0);
|
|
528
|
+
|
|
529
|
+
if (pos == -1) {
|
|
530
|
+
CampaignCampsReceiver campsReceiver = new CampaignCampsReceiver();
|
|
531
|
+
campsReceiver.sendCallback(bundle, context);
|
|
532
|
+
intent.removeExtra("pos");
|
|
533
|
+
} else {
|
|
534
|
+
handleActionClick(payload, notificationId, intent, pushClickData, pos, context);
|
|
535
|
+
}
|
|
536
|
+
}else
|
|
537
|
+
printLog("ActionPushDebug", " | bundle is null ");
|
|
538
538
|
}
|
|
539
539
|
} else
|
|
540
540
|
printLog("ActionPushDebug", " | intent is null ");
|
|
@@ -542,4 +542,89 @@ public class AppICEUtils {
|
|
|
542
542
|
printLog("ActionPushDebug"," | exception in null ");
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
|
+
|
|
546
|
+
private static void handleActionClick(String aiContent, int notificationId, Intent intent, NotificationClickHandler pushClickData, int pos, Context context) {
|
|
547
|
+
if (aiContent == null || aiContent.isEmpty()) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
try {
|
|
551
|
+
JSONObject payloadJson = new JSONObject(aiContent);
|
|
552
|
+
payloadJson.put("notificationId", notificationId);
|
|
553
|
+
payloadJson.put("selectedIndex", pos);
|
|
554
|
+
Campaign campaign = ContextSdk.handlePush(payloadJson.toString(), context);
|
|
555
|
+
Action selectedAction = campaign != null ? campaign.getSelectedAction() : null;
|
|
556
|
+
if (selectedAction != null) {
|
|
557
|
+
payloadJson.put("selectedAction", selectedAction.toJson());
|
|
558
|
+
} else {
|
|
559
|
+
ContextSdk.pushNotificationClicked(payloadJson.toString(), context);
|
|
560
|
+
}
|
|
561
|
+
handleCampaignAction(campaign,context);
|
|
562
|
+
pushClickData.deleteKeyFromIntent(intent, NotificationClickHandler.K_PAYLOAD);
|
|
563
|
+
} catch (Exception e) {
|
|
564
|
+
printLog("ActionPushDebug","Action button: action click failed - " + e.getMessage());
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
private static void handleCampaignAction(Campaign campaign, Context context) {
|
|
569
|
+
if (campaign == null) {
|
|
570
|
+
printLog("ActionPushDebug","Action button: campaign is null");
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
try {
|
|
575
|
+
Action selectedAction = campaign.getSelectedAction();
|
|
576
|
+
if (selectedAction == null) {
|
|
577
|
+
printLog("ActionPushDebug","Action button: selectedAction is null");
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
String actionType = selectedAction.getActionType() != null ? selectedAction.getActionType().toLowerCase(Locale.ROOT) : null;
|
|
581
|
+
String actionContent = selectedAction.getActionContent();
|
|
582
|
+
String actionTitle = selectedAction.getActionTitle();
|
|
583
|
+
String actionURL = selectedAction.getActionUrl();
|
|
584
|
+
|
|
585
|
+
printLog("ActionPushDebug","Action button clicked - type: " + actionType + ", title: " + actionTitle);
|
|
586
|
+
|
|
587
|
+
if (actionType == null) {
|
|
588
|
+
printLog("ActionPushDebug","Action button: action type is null");
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
switch (actionType) {
|
|
593
|
+
case "lp":
|
|
594
|
+
Utility.openExternalLinkUrl(actionURL, context);
|
|
595
|
+
break;
|
|
596
|
+
case "dl":
|
|
597
|
+
Utility.openDeepLinkUrl(actionURL, context);
|
|
598
|
+
break;
|
|
599
|
+
case "cp":
|
|
600
|
+
ContextSdk.copyToClipboard(actionContent, context);
|
|
601
|
+
break;
|
|
602
|
+
case "sh":
|
|
603
|
+
ContextSdk.shareActionContent(actionContent, actionContent, context);
|
|
604
|
+
break;
|
|
605
|
+
case "cus":
|
|
606
|
+
WritableMap params = Arguments.createMap();
|
|
607
|
+
JSONObject campaignJson = campaign.toJson();
|
|
608
|
+
if (campaignJson != null && campaignJson.length() > 0) {
|
|
609
|
+
String campaignStr = campaignJson.toString();
|
|
610
|
+
params.putString(EnumConstants.APPICE_PUSH_NOTIFICATION_ACTION_BUTTON_CLICKED.getValue(), campaignStr);
|
|
611
|
+
|
|
612
|
+
printLog("ActionPushDebug onActionButtonClicked", "action button clicked | campaign: " + campaignStr);
|
|
613
|
+
printLog("ActionPushDebug onActionButtonClicked", "isDeviceReadyFlag: " + isDeviceReadyFlag);
|
|
614
|
+
printLog("ActionPushDebug onActionButtonClicked", "queue size before send: " + pendingEventQueue.size());
|
|
615
|
+
AppIceReactPluginModule.sendEvent(EnumConstants.APPICE_PUSH_NOTIFICATION_ACTION_BUTTON_CLICKED.getValue(), params);
|
|
616
|
+
printLog("ActionPushDebug onActionButtonClicked", "queue size after send: " + pendingEventQueue.size());
|
|
617
|
+
} else {
|
|
618
|
+
printLog("ActionPushDebug onActionButtonClicked", "campaignJson is null or empty — event NOT sent");
|
|
619
|
+
}
|
|
620
|
+
break;
|
|
621
|
+
default:
|
|
622
|
+
printLog("ActionPushDebug","Action button: unknown action type - " + actionType);
|
|
623
|
+
break;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
} catch (Exception e) {
|
|
627
|
+
printLog("ActionPushDebug","Action button: handleCampaignAction failed - " + e.getMessage());
|
|
628
|
+
}
|
|
629
|
+
}
|
|
545
630
|
}
|
|
@@ -45,7 +45,10 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
|
|
|
45
45
|
AppIceReactPluginModule.sendEvent(EnumConstants.APPICE_INAPP_NOTIFICATION_CLICKED.getValue(), params);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
+
printLog("CampaignEvent |","sendCallback |isHTMLInApp "+isHTMLInApp+"| campaignStr "+campaignStr);
|
|
49
|
+
|
|
48
50
|
if (isHTMLInApp){
|
|
51
|
+
|
|
49
52
|
if (Utility.isValidObject(campaignStr)) {
|
|
50
53
|
WritableMap params = Arguments.createMap();
|
|
51
54
|
params.putString(EnumConstants.APPICE_HTML_INAPP_NOTIFICATION_CLICKED.getValue(), campaignStr);
|
|
@@ -59,6 +62,7 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
|
|
|
59
62
|
WritableMap params = Arguments.createMap();
|
|
60
63
|
if (pushContent != null){
|
|
61
64
|
params.putString(EnumConstants.APPICE_PUSH_NOTIFICATION_CLICKED.getValue(), pushContent.toString());
|
|
65
|
+
printLog("ActionPushDebug", " | APPICE_PUSH_NOTIFICATION_CLICKED | pushContent = "+pushContent);
|
|
62
66
|
AppIceReactPluginModule.sendEvent(EnumConstants.APPICE_PUSH_NOTIFICATION_CLICKED.getValue(), params);
|
|
63
67
|
}
|
|
64
68
|
}
|
|
@@ -52,6 +52,8 @@ public enum EnumConstants {
|
|
|
52
52
|
INBOX_MESSAGE_CATEGORY("INBOX_MESSAGE_CATEGORY"),
|
|
53
53
|
INBOX_MESSAGE_ICON("INBOX_MESSAGE_ICON"),
|
|
54
54
|
INBOX_CUSTOM_DATA("INBOX_CUSTOM_DATA"),
|
|
55
|
+
INBOX_EXPANDED_IMAGE("INBOX_EXPANDED_IMAGE"),
|
|
56
|
+
INBOX_ACTIONS("INBOX_ACTIONS"),
|
|
55
57
|
|
|
56
58
|
//==================================
|
|
57
59
|
// custom user data
|
|
@@ -211,6 +213,14 @@ public enum EnumConstants {
|
|
|
211
213
|
return StringConstants.INBOX_CUSTOM_DATA;
|
|
212
214
|
}
|
|
213
215
|
|
|
216
|
+
case INBOX_EXPANDED_IMAGE:{
|
|
217
|
+
return StringConstants.INBOX_EXPANDED_IMAGE;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
case INBOX_ACTIONS:{
|
|
221
|
+
return StringConstants.INBOX_ACTIONS;
|
|
222
|
+
}
|
|
223
|
+
|
|
214
224
|
case FIRST_SEEN:{
|
|
215
225
|
return StringConstants.FIRST_SEEN;
|
|
216
226
|
}
|
|
@@ -21,6 +21,8 @@ public interface StringConstants{
|
|
|
21
21
|
String INBOX_MESSAGE_CATEGORY = "category";
|
|
22
22
|
String INBOX_MESSAGE_ICON = "icon";
|
|
23
23
|
String INBOX_CUSTOM_DATA = "cdata";
|
|
24
|
+
String INBOX_EXPANDED_IMAGE = "expandedImage";
|
|
25
|
+
String INBOX_ACTIONS = "actions";
|
|
24
26
|
String FIRST_SEEN = "fsn";
|
|
25
27
|
String LAST_SEEN = "lsn";
|
|
26
28
|
String CUSTOM_DATA = "cdata";
|
package/ios/AppIceReactPlugin.m
CHANGED
|
@@ -440,6 +440,10 @@ RCT_EXPORT_METHOD(synchronizeInbox:(int)timeout callback:(RCTResponseSenderBlock
|
|
|
440
440
|
// Add a method to format AppICEInboxMessage to a dictionary
|
|
441
441
|
- (NSDictionary *)formatInboxMessage:(AppICEInboxMessage *)inboxMessage {
|
|
442
442
|
if (inboxMessage) {
|
|
443
|
+
NSMutableArray *actionButtons = [NSMutableArray array];
|
|
444
|
+
for (Action *action in inboxMessage.actions) {
|
|
445
|
+
[actionButtons addObject:[action toDictionary]];
|
|
446
|
+
}
|
|
443
447
|
return @{
|
|
444
448
|
@"messageId": inboxMessage.messageId,
|
|
445
449
|
@"id": inboxMessage.messageMid,
|
|
@@ -452,7 +456,8 @@ RCT_EXPORT_METHOD(synchronizeInbox:(int)timeout callback:(RCTResponseSenderBlock
|
|
|
452
456
|
@"cdata": inboxMessage.customData,
|
|
453
457
|
@"messageExpiryTime": @(inboxMessage.messageExpiryTime),
|
|
454
458
|
@"campType": inboxMessage.campType,
|
|
455
|
-
@"
|
|
459
|
+
@"expandedImage": inboxMessage.expandedImage, //messageExpandedImage replaced to expandedImage as discussed
|
|
460
|
+
@"actionButtons": actionButtons
|
|
456
461
|
};
|
|
457
462
|
} else {
|
|
458
463
|
return @{};
|
package/package.json
CHANGED