reactnative-plugin-appice 1.7.46 → 1.7.49

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.
@@ -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.44"
100
+ implementation "appice.io.android:sdk:2.6.46"
101
101
 
102
102
  //glide
103
103
  implementation "com.github.bumptech.glide:glide:4.11.0"
@@ -97,15 +97,6 @@
97
97
  android:permission="android.permission.BIND_JOB_SERVICE">
98
98
  </service>
99
99
 
100
- <receiver
101
- android:protectionLevel="signature"
102
- android:name="semusi.context.ui.Carousel.CarouselEventReceiver"
103
- android:exported="false">
104
- <intent-filter>
105
- <action android:name="io.appice.CAROUSELNOTIFICATIONFIRED" />
106
- </intent-filter>
107
- </receiver>
108
-
109
100
  <receiver
110
101
  android:name="semusi.ruleengine.pushmanager.AppICEMessageHandler"
111
102
  android:exported="true"
@@ -3,6 +3,8 @@ package com.appice.react;
3
3
  import static com.appice.react.AppIceReactPluginModule.isDeviceReadyFlag;
4
4
  import static com.appice.react.AppIceReactPluginModule.pendingEventQueue;
5
5
 
6
+ import static semusi.ruleengine.pushmanager.NotificationClickHandler.K_PAYLOAD;
7
+
6
8
  import android.content.Context;
7
9
  import android.content.Intent;
8
10
  import android.os.Bundle;
@@ -25,6 +27,7 @@ import java.util.Arrays;
25
27
  import java.util.HashMap;
26
28
  import java.util.Iterator;
27
29
  import java.util.List;
30
+ import java.util.Locale;
28
31
  import java.util.Map;
29
32
 
30
33
  import org.json.JSONArray;
@@ -35,6 +38,7 @@ import semusi.context.counthandler.CampaignActionListener;
35
38
  import semusi.context.ui.appInbox.AppICEInboxMessage;
36
39
 
37
40
  import semusi.context.utility.Utility;
41
+ import semusi.model.campaign.Action;
38
42
  import semusi.model.campaign.Campaign;
39
43
  import semusi.model.user.User;
40
44
  import semusi.ruleengine.pushmanager.NotificationClickHandler;
@@ -170,8 +174,22 @@ public class AppICEUtils {
170
174
  inboxObject.putString(EnumConstants.INBOX_MESSAGE.getValue(), inboxMessage.getMessageBody());
171
175
  inboxObject.putString(EnumConstants.INBOX_MESSAGE_ICON.getValue(), inboxMessage.getMessageIcon());
172
176
  inboxObject.putMap(EnumConstants.INBOX_CUSTOM_DATA.getValue(), toWritableMap(inboxMessage.getCustomData()));
177
+ inboxObject.putString(EnumConstants.INBOX_EXPANDED_IMAGE.getValue(), inboxMessage.getExpandedImage());
178
+ List<Action> actionList = inboxMessage.getActions();
179
+ if (actionList !=null && !actionList.isEmpty()){
180
+ ArrayList<String> actionArray = new ArrayList<>();
181
+ for (int i = 0; i < actionList.size(); i++) {
182
+ Action action = actionList.get(i);
183
+ if (action !=null) {
184
+ actionArray.add(action.toJson().toString());
185
+ }
186
+ }
187
+ WritableArray writableArray = toWritableArray(actionArray);
188
+ inboxObject.putArray(EnumConstants.INBOX_ACTIONS.getValue(), writableArray);
189
+ }
173
190
  }
174
191
  } catch (Throwable throwable) {
192
+ Utility.loginfo("exception in convertClassToWritableMap "+throwable);
175
193
  }
176
194
  return inboxObject;
177
195
  }
@@ -502,44 +520,98 @@ public class AppICEUtils {
502
520
  // this function will handle both normal push and action button push.
503
521
  // through listner user will identify.
504
522
  public static void handleClickOnPush(Intent intent, Context context) {
523
+ if (intent == null) {
524
+ printLog("ActionPushDebug", "Intent is null");
525
+ return;
526
+ }
527
+
528
+ Bundle bundle = intent.getExtras();
529
+ if (bundle == null) {
530
+ printLog("ActionPushDebug", "Bundle is null");
531
+ return;
532
+ }
533
+
534
+ NotificationClickHandler pushClickData = null;
535
+
505
536
  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
- }
537
+ pushClickData = NotificationClickHandler.fromBundle(bundle);
538
+ String payload = pushClickData.getPayload();
539
+
540
+ if (!Utility.isValidObject(payload)) {
541
+ return;
542
+ }
543
+
544
+ JSONObject payloadJson = new JSONObject(payload);
545
+ int pos = bundle.getInt("pos", -1);
546
+ int notificationId = bundle.getInt("n", -1);
547
+
548
+ // Notification body click
549
+ if (pos == -1) {
550
+ if (ContextSdk.isPayloadHaveExternalUrl(payload)) {
551
+ ContextSdk.pushNotificationClicked(payload, context);
552
+ ContextSdk.handleExternalUrl(payload, context);
553
+ return;
538
554
  }
539
- } else
540
- printLog("ActionPushDebug", " | intent is null ");
541
- } catch (Throwable e) {
542
- printLog("ActionPushDebug"," | exception in null ");
555
+
556
+ CampaignCampsReceiver campsReceiver = new CampaignCampsReceiver();
557
+ campsReceiver.sendCallback(bundle, context);
558
+ return;
559
+ }
560
+
561
+ // Notification action button click
562
+ if (notificationId >= 0) {
563
+ payloadJson.put("notificationId", notificationId);
564
+ }
565
+ payloadJson.put("selectedIndex", pos);
566
+
567
+ Campaign campaign = ContextSdk.handlePush(payloadJson.toString(), context);
568
+
569
+ if (campaign == null) {
570
+ return;
571
+ }
572
+
573
+ Action action = campaign.getSelectedAction();
574
+ if (action == null) {
575
+ return;
576
+ }
577
+
578
+ String type = action.getActionType();
579
+
580
+ if (Utility.isValidObject(type) && (type.equalsIgnoreCase("lp") || type.equalsIgnoreCase("dl"))) {
581
+ Map<String, Object> map = new HashMap<>();
582
+ map.put("campid", campaign.getCampId());
583
+ map.put("abt", action.getActionTitle());
584
+ map.put("mid", campaign.getMessageId());
585
+ ContextSdk.tagEventObj("Campaign_Clicked", map, context);
586
+
587
+ if (type.equalsIgnoreCase("lp")) {
588
+ Utility.openExternalLinkUrl(action.getActionUrl(), context);
589
+ } else {
590
+ Utility.openDeepLinkUrl(action.getActionUrl(), context);
591
+ }
592
+ return;
593
+ }
594
+
595
+ WritableMap params = Arguments.createMap();
596
+ String campaignStr = campaign.toJson().toString();
597
+
598
+ params.putString(EnumConstants.APPICE_PUSH_NOTIFICATION_ACTION_BUTTON_CLICKED.getValue(), campaignStr);
599
+
600
+ printLog("ActionPushDebug onActionButtonClicked", "action button clicked | campaign: " + campaignStr);
601
+ printLog("ActionPushDebug onActionButtonClicked", "isDeviceReadyFlag: " + isDeviceReadyFlag);
602
+ printLog("ActionPushDebug onActionButtonClicked", "queue size before send: " + pendingEventQueue.size());
603
+
604
+ AppIceReactPluginModule.sendEvent(EnumConstants.APPICE_PUSH_NOTIFICATION_ACTION_BUTTON_CLICKED.getValue(), params);
605
+
606
+ printLog("ActionPushDebug onActionButtonClicked", "queue size after send: " + pendingEventQueue.size());
607
+
608
+ } catch (Exception e) {
609
+ printLog("ActionPushDebug","Notification click handling failed: " + e.getMessage());
610
+ } finally {
611
+ // Executes even when an earlier branch returns.
612
+ if (pushClickData != null) {
613
+ pushClickData.deleteKeyFromIntent(intent, K_PAYLOAD);
614
+ }
543
615
  }
544
616
  }
545
- }
617
+ }
@@ -45,6 +45,7 @@ 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);
48
49
  if (isHTMLInApp){
49
50
  if (Utility.isValidObject(campaignStr)) {
50
51
  WritableMap params = Arguments.createMap();
@@ -59,6 +60,7 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
59
60
  WritableMap params = Arguments.createMap();
60
61
  if (pushContent != null){
61
62
  params.putString(EnumConstants.APPICE_PUSH_NOTIFICATION_CLICKED.getValue(), pushContent.toString());
63
+ printLog("ActionPushDebug", " | APPICE_PUSH_NOTIFICATION_CLICKED | pushContent = "+pushContent);
62
64
  AppIceReactPluginModule.sendEvent(EnumConstants.APPICE_PUSH_NOTIFICATION_CLICKED.getValue(), params);
63
65
  }
64
66
  }
@@ -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/campaign.js CHANGED
@@ -1,39 +1,11 @@
1
- const { Linking, Platform } = require('react-native');
2
1
 
3
- async function handleClickOnPush(campaign) {
4
- if (campaign && campaign._data) {
5
- campaign = campaign._data;
6
- }
7
-
8
- const url = campaign.actionUrl || campaign.acu || campaign.eurl;
9
- const actionType = campaign.actionType || campaign.act || campaign.et;
10
-
11
- if (!url || typeof url !== 'string') {
12
- console.log('Error: URL is not provided.');
13
- return;
14
- }
15
-
16
- const httpUrls = url.startsWith('http://') || url.startsWith('https://');
17
-
18
- if (httpUrls) {
19
- try {
20
- if (Platform.OS === 'ios') {
21
- campaign = normalizeCampaignPayloadForPlatform(campaign);
22
- return campaign;
23
- // iOS handle redirection on native side for landing page.
24
- }
25
-
26
- await Linking.openURL(url);
27
- console.log(`Successfully opened URL: ${url}`);
28
- } catch (error) {
29
- console.log('Error while opening URL:', error?.message || error);
30
- }
31
- }
2
+ const { Platform } = require('react-native');
32
3
 
33
- if (actionType === 'dl' && !httpUrls) {
34
- // handle custom deeplink
4
+ async function handleClickOnPush(campaign) {
5
+ // not removing this fucntion, as UBI is using it for IOS and IOS was returning campaign class object without checking anything
6
+ campaign = normalizeCampaignPayloadForPlatform(campaign);
35
7
  return campaign;
36
- }
8
+
37
9
  }
38
10
 
39
11
 
@@ -73,7 +45,7 @@ class Campaign {
73
45
  // if parse fails, keep eventData as-is (object expected)
74
46
  data = eventData || {};
75
47
  }
76
-
48
+
77
49
  // Keep app-side listener thin by normalizing payload shape in campaign layer.
78
50
  data = normalizeCampaignPayloadForPlatform(data);
79
51
  const isLegacy = data && (data.camp_id || data.eurl || data.et || data.abt || data.act || data.acc);
@@ -81,6 +53,7 @@ class Campaign {
81
53
  if (isLegacy) {
82
54
  // Map legacy fields into _data in a normalized way
83
55
  this._data.campId = data.campId || data.camp_id || '';
56
+ this._data.mid = data.mid || '';
84
57
  this._data.actionType = data.actionType || data.et || data.act || '';
85
58
  this._data.actionUrl = data.actionUrl || data.eurl || data.acu || '';
86
59
  this._data.actionContent = data.actionContent || data.acc || '';
@@ -94,8 +67,9 @@ class Campaign {
94
67
  this._data.customData = data.customData || data.cdata || data.custom || {};
95
68
 
96
69
  // Actions mapping (legacy may have abt/act/acc/acu)
97
- this._data.actions = Array.isArray(data.actions)
98
- ? data.actions.map((action) => ({
70
+ const actions = data.actions || data.actionButtons;
71
+ this._data.actions = Array.isArray(actions)
72
+ ? actions.map((action) => ({
99
73
  actionTitle: action.actionTitle || action.abt || '',
100
74
  actionType: action.actionType || action.act || '',
101
75
  actionContent: action.actionContent || action.acc || '',
@@ -117,6 +91,7 @@ class Campaign {
117
91
  // ===========================
118
92
  toCampaign(jsonData) {
119
93
  this._data.campId = jsonData.campId || jsonData.camp_id || '';
94
+ this._data.mid = jsonData.mid || '';
120
95
  this._data.nh = jsonData.title || jsonData.nh || '';
121
96
  this._data.nd = jsonData.description || jsonData.nd || '';
122
97
  this._data.end = jsonData.expandedDescription || jsonData.end || '';
@@ -131,8 +106,9 @@ class Campaign {
131
106
  this._data.expiry = jsonData.expiry || 0;
132
107
  this._data.customData = jsonData.customData || jsonData.custom || {};
133
108
  // Actions array mapping
134
- this._data.actions = Array.isArray(jsonData.actions)
135
- ? jsonData.actions.map(function (action) {
109
+ const actions = jsonData.actions || jsonData.actionButtons;
110
+ this._data.actions = Array.isArray(actions)
111
+ ? actions.map(function (action) {
136
112
  return {
137
113
  actionTitle: action.actionTitle || action.abt || '',
138
114
  actionType: action.actionType || action.act || '',
@@ -215,6 +191,9 @@ class Campaign {
215
191
  getCampaignId() {
216
192
  return this._data.campId || this._data.camp_id || '';
217
193
  }
194
+ getMid() {
195
+ return this._data.mid || '';
196
+ }
218
197
  getActionUrl() {
219
198
  return this._data.actionUrl || this._data.acu || this._data.eurl || '';
220
199
  }
@@ -243,6 +222,23 @@ class Campaign {
243
222
  return this._data.selectedActionUrl;
244
223
  }
245
224
 
225
+ // ===========================
226
+ // Campaign Click Tracking
227
+ // ===========================
228
+ async pushActionNotificationClicked(AppICE) {
229
+ const dataObj = {
230
+ campid: this.getCampaignId(),
231
+ abt: this.getSelectedActionTitle(),
232
+ mid: this.getMid()
233
+ };
234
+
235
+ try {
236
+ await AppICE.tagEvent('Campaign_Clicked', dataObj);
237
+ } catch (error) {
238
+ console.error('Campaign_Clicked tracking failed:', error);
239
+ }
240
+ }
241
+
246
242
  // Convert to JSON
247
243
  toJSON() {
248
244
  return this._data;
@@ -17,7 +17,7 @@
17
17
  "install": "^0.13.0",
18
18
  "react": "18.0.0",
19
19
  "react-native": "0.69.4",
20
- "reactnative-plugin-appice": "1.7.43",
20
+ "reactnative-plugin-appice": "1.7.48",
21
21
  "react-native-mmkv": "2.12.2"
22
22
  },
23
23
  "devDependencies": {
@@ -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
- @"eni": inboxMessage.expandedImage //messageExpandedImage replaced to expandedImage as discussed
459
+ @"expandedImage": inboxMessage.expandedImage, //messageExpandedImage replaced to expandedImage as discussed
460
+ @"actions": actionButtons
456
461
  };
457
462
  } else {
458
463
  return @{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactnative-plugin-appice",
3
- "version": "1.7.46",
3
+ "version": "1.7.49",
4
4
  "description": "appICE React Native SDK",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -23,7 +23,7 @@ Pod::Spec.new do |s|
23
23
  s.requires_arc = true
24
24
 
25
25
  s.dependency "React"
26
- s.dependency "AppICE-IOS-SDK", "1.8.27"
26
+ s.dependency "AppICE-IOS-SDK", "1.8.28"
27
27
  # ...
28
28
  # s.dependency "..."
29
29
  end
File without changes
File without changes