cordova-plugin-appice 2.2.5 → 2.2.6

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.
@@ -15,7 +15,7 @@
15
15
  "devDependencies": {
16
16
  "cordova-android": "^10.1.2",
17
17
  "cordova-ios": "^6.3.0",
18
- "cordova-plugin-appice": "^2.2.1",
18
+ "cordova-plugin-appice": "^2.2.6",
19
19
  "cordova-plugin-device": "^2.1.0",
20
20
  "cordova-plugin-dialogs": "^2.0.2",
21
21
  "cordova-plugin-file": "^7.0.0",
@@ -46,6 +46,32 @@ function onDeviceReady() {
46
46
  });
47
47
 
48
48
  initializesdk()
49
+
50
+ // INAPP CTA callback
51
+ AppICE.sendClickCallback(function (data) {
52
+ console.log("Received INAPP click data:", data);
53
+ alert("Received INAPP click data: " + JSON.stringify(data));
54
+ }, function (err) {
55
+ console.error("Error in click callback:", err);
56
+ });
57
+
58
+ document.addEventListener('pause', function () {
59
+ console.log("App is in background, calling suspendInApp");
60
+ AppICE.suspendInApp(
61
+ () => console.log("suspendInApp success"),
62
+ (err) => console.error("suspendInApp error:", err)
63
+ );
64
+ }, false);
65
+
66
+
67
+ document.addEventListener('resume', function () {
68
+ console.log("App is in foreground, calling resumeInApp");
69
+ AppICE.resumeInApp(
70
+ () => console.log("resumeInApp success"),
71
+ (err) => console.error("resumeInApp error:", err)
72
+ );
73
+ }, false);
74
+
49
75
  onResume()
50
76
  }
51
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-appice",
3
- "version": "2.2.5",
3
+ "version": "2.2.6",
4
4
  "description": "AppICE Plugin for Cordova/PhoneGap",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-appice",
package/plugin.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
3
- id="cordova-plugin-appice" version="2.2.5">
3
+ id="cordova-plugin-appice" version="2.2.6">
4
4
  <name>AppICE</name>
5
5
  <description>AppICE Plugin for Cordova/PhoneGap</description>
6
6
  <license>Commercial</license>
@@ -41,7 +41,7 @@
41
41
 
42
42
  <podspec>
43
43
  <pods>
44
- <pod name="AppICE-IOS-SDK" spec="1.7.87" />
44
+ <pod name="AppICE-IOS-SDK" spec="1.8.01" />
45
45
  </pods>
46
46
  </podspec>
47
47
 
@@ -121,7 +121,7 @@
121
121
  <preference name="MEDIA3_UI_VERSION" default="1.0.2"/>
122
122
 
123
123
  <!-- AppICE VERSION-->
124
- <preference name="APPICE_VERSION" default="2.5.96"/>
124
+ <preference name="APPICE_VERSION" default="2.6.12"/>
125
125
 
126
126
 
127
127
  <!-- USES PERMISSION -->
@@ -158,15 +158,6 @@
158
158
  <action android:name="AppICE.Notification.FCM_Action"/>
159
159
  <category android:name="android.intent.category.DEFAULT"/>
160
160
  </intent-filter>
161
-
162
- <intent-filter>
163
- <action android:name="android.intent.action.VIEW"/>
164
-
165
- <category android:name="android.intent.category.DEFAULT"/>
166
- <category android:name="android.intent.category.BROWSABLE"/>
167
-
168
- <data android:host="ai.io" android:scheme="https"/>
169
- </intent-filter>
170
161
  </activity>
171
162
 
172
163
  <service android:name="semusi.ruleengine.pushmanager.SdkFcmListenerService"
@@ -187,6 +178,7 @@
187
178
  <source-file src="src/android/AppICEFCMPush.java" target-dir="com/appice/cordova/" />
188
179
  <source-file src="src/android/AppICEPushHandler.java" target-dir="com/appice/cordova/" />
189
180
  <source-file src="src/android/AppICEPlugin.java" target-dir="com/appice/cordova/" />
181
+ <source-file src="src/android/ClickCallback.java" target-dir="com/appice/cordova/" />
190
182
  <source-file src="src/android/CampaignCampsReceiver.java" target-dir="com/appice/cordova/" />
191
183
  <source-file src="src/android/NotificationEventService.java" target-dir="com/appice/cordova/" />
192
184
 
@@ -36,6 +36,8 @@ import semusi.activitysdk.Api;
36
36
  import semusi.activitysdk.ContextData;
37
37
  import semusi.activitysdk.ContextSdk;
38
38
  import semusi.activitysdk.SdkConfig;
39
+ import semusi.context.ui.AlertPopupData;
40
+ import semusi.geofencing.AIGeofenceController;
39
41
  import semusi.model.user.User;
40
42
  import semusi.context.utility.Utility;
41
43
  import org.json.JSONException;
@@ -93,7 +95,7 @@ public class AppICEPlugin extends CordovaPlugin {
93
95
 
94
96
  @Override
95
97
  public void onDestroy() {
96
-
98
+
97
99
  }
98
100
 
99
101
  @Override
@@ -130,7 +132,8 @@ public class AppICEPlugin extends CordovaPlugin {
130
132
  String url = data.optString("eurl");
131
133
  handleLandingPage(url, cordova.getActivity().getApplicationContext());
132
134
  } else {
133
- final String json = "{'payload':" + data.toString() + "}";
135
+ JSONObject json = new JSONObject();
136
+ json.put("payload", data);
134
137
  System.out.println("AppICE : onNewIntent : json " + json);
135
138
  if (statusFlag) {
136
139
  webView.getView().post(new Runnable() {
@@ -140,7 +143,7 @@ public class AppICEPlugin extends CordovaPlugin {
140
143
  }
141
144
  });
142
145
  } else {
143
- storeTempData(CALLBACK_CONSTANTS, json, cordova.getActivity());
146
+ storeTempData(CALLBACK_CONSTANTS, json.toString(), cordova.getActivity());
144
147
  }
145
148
  }
146
149
  ContextSdk.pushNotificationClicked(payload, cordova.getActivity().getApplicationContext());
@@ -276,16 +279,19 @@ public class AppICEPlugin extends CordovaPlugin {
276
279
 
277
280
  private void checkIfAnyPendingCallback(Context context) {
278
281
  String pendingCallbackStr = loadTempData(CALLBACK_CONSTANTS, context);
279
- webView.getView().post(new Runnable() {
280
- @Override
281
- public void run() {
282
- webView.loadUrl(
283
- "javascript:cordova.fireDocumentEvent('pushNotificationClicked'," + pendingCallbackStr + ");");
284
- resetTempData(CALLBACK_CONSTANTS, context);
282
+ try {
283
+ if (Utility.isValidObject(pendingCallbackStr)) {
284
+ JSONObject jsonObject = new JSONObject(pendingCallbackStr);
285
+ webView.getView().post(new Runnable() {
286
+ @Override
287
+ public void run() {
288
+ webView.loadUrl("javascript:cordova.fireDocumentEvent('pushNotificationClicked'," + jsonObject + ");");
289
+ resetTempData(CALLBACK_CONSTANTS, context);
290
+ }
291
+ });
285
292
  }
286
- });
293
+ }catch (Throwable e) {}
287
294
  }
288
-
289
295
  @CordovaMethod
290
296
  private void stopContext(JSONArray data, CallbackContext callbackContext) {
291
297
  try {
@@ -1030,13 +1036,13 @@ public class AppICEPlugin extends CordovaPlugin {
1030
1036
  /**
1031
1037
  * Get inbox messages list.
1032
1038
  *
1033
- * @param type the message type
1039
+ * the message type
1034
1040
  * 1 = ALL
1035
1041
  * 2 = UNREAD
1036
1042
  * 3 = READ
1037
1043
  * 4 = VIEWED
1038
1044
  * 5 = DELETED
1039
- * @param userIds the same way we are passing the value in setUserId same value
1045
+ * the same way we are passing the value in setUserId same value
1040
1046
  * we need here. ie. [ "useridA" ]
1041
1047
  * @callback will have the string json array
1042
1048
  */
@@ -1084,7 +1090,7 @@ public class AppICEPlugin extends CordovaPlugin {
1084
1090
  /**
1085
1091
  * Get inbox messages list.
1086
1092
  *
1087
- * @param type the message type
1093
+ * the message type
1088
1094
  * 1 = ALL
1089
1095
  * 2 = UNREAD
1090
1096
  * 3 = READ
@@ -1121,7 +1127,7 @@ public class AppICEPlugin extends CordovaPlugin {
1121
1127
  /**
1122
1128
  * Get appinbox cData through mediakey
1123
1129
  * mediakey is a kind of key just like in json we find key value
1124
- *
1130
+ *
1125
1131
  * @param {inboxMessage} ReadableMap
1126
1132
  * @param {String} mediakey : will get this key from cData json
1127
1133
  * @Callback will recive Map<String, Object> object
@@ -1152,7 +1158,7 @@ public class AppICEPlugin extends CordovaPlugin {
1152
1158
  * To get Media URL from getMediaData
1153
1159
  * inboxMessage {AppICEInboxMessage as a ReadableMap}
1154
1160
  * mediaData customData
1155
- *
1161
+ *
1156
1162
  * @callback callback will receive mediaUrl{string}
1157
1163
  */
1158
1164
  @CordovaMethod
@@ -1180,7 +1186,7 @@ public class AppICEPlugin extends CordovaPlugin {
1180
1186
  * To get Media type from customdata
1181
1187
  * inboxMessage {AppICEInboxMessage as a ReadableMap}
1182
1188
  * mediaData customData : this we will recived from getmediadata callback
1183
- *
1189
+ *
1184
1190
  * @callback callback will receive mediaType{string}
1185
1191
  */
1186
1192
  @CordovaMethod
@@ -1209,7 +1215,7 @@ public class AppICEPlugin extends CordovaPlugin {
1209
1215
  * To get Media Thumbnail from customdata
1210
1216
  * inboxMessage {AppICEInboxMessage as a ReadableMap}
1211
1217
  * mediaData customData : this we will recived from getmediadata callback
1212
- *
1218
+ *
1213
1219
  * @callback callback will receive Thumbnail{string}
1214
1220
  */
1215
1221
  @CordovaMethod
@@ -1252,13 +1258,13 @@ public class AppICEPlugin extends CordovaPlugin {
1252
1258
  /**
1253
1259
  * Get inbox messages count.
1254
1260
  *
1255
- * @param type the message type
1261
+ * the message type
1256
1262
  * 1 = ALL
1257
1263
  * 2 = UNREAD
1258
1264
  * 3 = READ
1259
1265
  * 4 = VIEWED
1260
1266
  * 5 = DELETED
1261
- * @param userIds the same way we are passing the value in setUserId same value
1267
+ * the same way we are passing the value in setUserId same value
1262
1268
  * we need here. ie. [ "useridA" ]
1263
1269
  * @callback will have the integer
1264
1270
  */
@@ -1289,10 +1295,10 @@ public class AppICEPlugin extends CordovaPlugin {
1289
1295
  callbackContext.error(e.getMessage());
1290
1296
  }
1291
1297
  }
1292
- /**
1298
+ /**
1293
1299
  * Get inbox messages count.
1294
1300
  *
1295
- * @param type the message type
1301
+ * the message type
1296
1302
  * 1 = ALL
1297
1303
  * 2 = UNREAD
1298
1304
  * 3 = READ
@@ -1315,9 +1321,6 @@ public class AppICEPlugin extends CordovaPlugin {
1315
1321
 
1316
1322
  /**
1317
1323
  * Get messages payload based on message id.
1318
- *
1319
- * @param messageId - message id of the notification
1320
- * @param userId - single userid in string ie. "useridA"
1321
1324
  * @callback will have the json object
1322
1325
  */
1323
1326
  @CordovaMethod
@@ -1336,10 +1339,9 @@ public class AppICEPlugin extends CordovaPlugin {
1336
1339
  }
1337
1340
  }
1338
1341
 
1339
- /**
1342
+ /**
1340
1343
  * Get messages payload based on message id.
1341
1344
  *
1342
- * @param messageId - message id of the notification
1343
1345
  * @callback will have the json object
1344
1346
  */
1345
1347
  @CordovaMethod
@@ -1358,12 +1360,9 @@ public class AppICEPlugin extends CordovaPlugin {
1358
1360
  }
1359
1361
 
1360
1362
 
1361
- /**
1363
+ /**
1362
1364
  * update message status ex. UNREAD to READ.
1363
1365
  *
1364
- * @param messageId - message id of the notification
1365
- * @param type - integer value for status
1366
- * @param userId - single userid in string
1367
1366
  * @callback will have the boolean
1368
1367
  */
1369
1368
  @CordovaMethod
@@ -1373,7 +1372,7 @@ public class AppICEPlugin extends CordovaPlugin {
1373
1372
  String messageId = object.optString("messageId");
1374
1373
  int type = object.optInt("type");
1375
1374
  String userId = object.optString("userId");
1376
-
1375
+
1377
1376
  if (userId != null) {
1378
1377
  boolean isUpdated = ContextSdk.updatedInboxMessage(messageId, type, userId,
1379
1378
  cordova.getActivity().getApplicationContext());
@@ -1385,11 +1384,11 @@ public class AppICEPlugin extends CordovaPlugin {
1385
1384
  }
1386
1385
 
1387
1386
  /**
1388
- * Updates the status of an inbox message.
1389
- *
1390
- * @param data A JSONArray containing the message ID and update type.
1391
- * @param callbackContext The callback context to return the result.
1392
- */
1387
+ * Updates the status of an inbox message.
1388
+ *
1389
+ * @param data A JSONArray containing the message ID and update type.
1390
+ * @param callbackContext The callback context to return the result.
1391
+ */
1393
1392
  @CordovaMethod
1394
1393
  private void updateInboxMessage(JSONArray data, CallbackContext callbackContext) {
1395
1394
  try {
@@ -1403,11 +1402,10 @@ public class AppICEPlugin extends CordovaPlugin {
1403
1402
  }
1404
1403
  }
1405
1404
 
1406
-
1405
+
1407
1406
  /**
1408
1407
  * To sync with server if server will have any new data to update.
1409
1408
  *
1410
- * @param timeout - integer value for status
1411
1409
  * @callback will have the boolean
1412
1410
  */
1413
1411
  @CordovaMethod
@@ -1430,9 +1428,6 @@ public class AppICEPlugin extends CordovaPlugin {
1430
1428
  * this method takes user id in form of Array and return User class objects and
1431
1429
  * return them
1432
1430
  * from callback
1433
- *
1434
- * @param userIds An array of user IDs
1435
- * @param callback will return instance of User class
1436
1431
  */
1437
1432
  @CordovaMethod
1438
1433
  private void getUserForIds(JSONArray data, CallbackContext callbackContext) {
@@ -1488,12 +1483,12 @@ public class AppICEPlugin extends CordovaPlugin {
1488
1483
  }
1489
1484
  }
1490
1485
 
1491
- /**
1492
- * Schedules a campaign with the given ID, duration, and user ID.
1493
- *
1494
- * @param data A JSONArray containing the campaign parameters.
1495
- * @param callbackContext The callback context to return the result.
1496
- */
1486
+ /**
1487
+ * Schedules a campaign with the given ID, duration, and user ID.
1488
+ *
1489
+ * @param data A JSONArray containing the campaign parameters.
1490
+ * @param callbackContext The callback context to return the result.
1491
+ */
1497
1492
  @CordovaMethod
1498
1493
  private void scheduleCampaign(JSONArray data, CallbackContext callbackContext) {
1499
1494
  try {
@@ -1510,4 +1505,105 @@ public class AppICEPlugin extends CordovaPlugin {
1510
1505
  }
1511
1506
  }
1512
1507
 
1513
- }
1508
+ //==================================
1509
+ // GEOFENCE
1510
+ //==================================
1511
+
1512
+ @CordovaMethod
1513
+ private void registerGeofence(JSONArray data, final CallbackContext callbackContext) {
1514
+ try {
1515
+ AIGeofenceController.getInstance().register(cordova.getActivity().getApplicationContext());
1516
+ callbackContext.success();
1517
+ } catch (Throwable e) {
1518
+ callbackContext.error(e.getMessage());
1519
+ Utility.loginfo("registerGeofence: error "+e);
1520
+ }
1521
+ }
1522
+
1523
+ @CordovaMethod
1524
+ public void handleCustomAlert(String title, String message, String alertUrl, Context context) {
1525
+ try {
1526
+ AlertPopupData alertPopupData = new AlertPopupData();
1527
+ alertPopupData.setTitle(title);
1528
+ alertPopupData.setMessage(message);
1529
+ alertPopupData.setUrl(alertUrl);
1530
+ Utility.showCustomAlertPopup(cordova.getActivity().getApplicationContext(),alertPopupData);
1531
+ callbackContext.success();
1532
+ } catch (Throwable e) {
1533
+ callbackContext.error(e.getMessage());
1534
+ Utility.loginfo("registerGeofence: error "+e);
1535
+ }
1536
+ }
1537
+
1538
+ @CordovaMethod
1539
+ private void resumeInApp(JSONArray data, CallbackContext callbackContext) {
1540
+ try {
1541
+ ContextSdk.resumeInApp(cordova.getActivity().getApplicationContext());
1542
+ callbackContext.success();
1543
+ } catch (Throwable e) {
1544
+ callbackContext.error(e.getMessage());
1545
+ }
1546
+ }
1547
+
1548
+ @CordovaMethod
1549
+ private void suspendInApp(JSONArray data, CallbackContext callbackContext) {
1550
+ try {
1551
+ ContextSdk.suspendInApp(cordova.getActivity().getApplicationContext());
1552
+ callbackContext.success();
1553
+ } catch (Throwable e) {
1554
+ callbackContext.error(e.getMessage());
1555
+ }
1556
+ }
1557
+
1558
+ @CordovaMethod
1559
+ private void discardInApp(JSONArray data, CallbackContext callbackContext) {
1560
+ try {
1561
+ ContextSdk.discardInApp(cordova.getActivity().getApplicationContext());
1562
+ callbackContext.success();
1563
+ } catch (Throwable e) {
1564
+ callbackContext.error(e.getMessage());
1565
+ }
1566
+ }
1567
+
1568
+ @CordovaMethod
1569
+ private void dismissInApp(JSONArray data, CallbackContext callbackContext) {
1570
+ try {
1571
+ ContextSdk.dismissInApp();
1572
+ callbackContext.success();
1573
+ } catch (Throwable e) {
1574
+ callbackContext.error(e.getMessage());
1575
+ }
1576
+ }
1577
+
1578
+ @CordovaMethod
1579
+ private void sendClickCallback(JSONArray data, CallbackContext callbackContext) {
1580
+ try {
1581
+ Context context = cordova.getActivity().getApplicationContext();
1582
+ Handler handler = new Handler(context.getMainLooper());
1583
+ handler.post(new Runnable() {
1584
+ @Override
1585
+ public void run() {
1586
+ ClickCallback clickCallback = new ClickCallback() {
1587
+ @Override
1588
+ public void clickPayload(String obj) {
1589
+ if (Utility.isValidObject(obj)) {
1590
+ if (callbackContext != null) {
1591
+ try {
1592
+ Utility.loginfo("AppICEPlugin : sendClickCallback : " + obj);
1593
+ callbackContext.success(obj);
1594
+ } catch (Throwable e) {
1595
+ Utility.loginfo("AppICEPlugin : sendClickCallback : error " + e);
1596
+ }
1597
+ }
1598
+ }
1599
+ }
1600
+ };
1601
+ CampaignCampsReceiver campaignCampsReceiver = new CampaignCampsReceiver(clickCallback);
1602
+ }
1603
+ });
1604
+ callbackContext.success();
1605
+ } catch (Throwable e) {
1606
+ callbackContext.error(e.getMessage());
1607
+ }
1608
+ }
1609
+ }
@@ -12,9 +12,16 @@ import java.util.HashMap;
12
12
  import java.util.Iterator;
13
13
  import java.util.Set;
14
14
  import semusi.activitysdk.ContextSdk;
15
+ import semusi.context.utility.Utility;
15
16
 
16
17
  public class CampaignCampsReceiver extends BroadcastReceiver {
17
18
  private static final String TAG = CampaignCampsReceiver.class.getSimpleName();
19
+ public static ClickCallback clickCallback;
20
+ public CampaignCampsReceiver() {}
21
+
22
+ public CampaignCampsReceiver(ClickCallback clickCallback) {
23
+ this.clickCallback = clickCallback;
24
+ }
18
25
 
19
26
  @Override
20
27
  public void onReceive(Context context, Intent intent) {
@@ -33,9 +40,19 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
33
40
  String url = extra.getString("url");
34
41
  String cdata = extra.getString("cdata");
35
42
  String pushCallback = extra.getString("ai_content");
43
+ boolean inApp = extra.getBoolean("ai_inapp");
36
44
 
37
45
  JSONObject json = new JSONObject();
38
46
 
47
+ if (inApp) {
48
+ if (cdata != null && cdata.length() > 0) {
49
+ if (clickCallback != null) {
50
+ clickCallback.clickPayload(cdata);
51
+ Utility.loginfo("CampaignRec : clickCallback "+cdata);
52
+ } else
53
+ Utility.loginfo("callback is null");
54
+ }
55
+ }
39
56
  try {
40
57
  // gather deeplink data
41
58
  if (url != null && url.length() > 0) {
@@ -0,0 +1,6 @@
1
+ package com.appice.cordova;
2
+
3
+ public interface ClickCallback {
4
+ void clickPayload(String obj);
5
+
6
+ }
package/src/build.gradle CHANGED
@@ -6,7 +6,7 @@ allprojects {
6
6
  url "https://gitlab.com/api/v4/projects/10636887/packages/maven"
7
7
  credentials(HttpHeaderCredentials) {
8
8
  name = "Deploy-Token"
9
- value = "PJMsxXdArqsmqDx4x5B6"
9
+ value = "gldt-ayJbLQtEd-nfQG6puvoD"
10
10
  }
11
11
  authentication {
12
12
  header(HttpHeaderAuthentication)
@@ -28,6 +28,7 @@ static NSString* const AIHandleActionNotification = @"AIHandleActionNotification
28
28
 
29
29
  @property (nonatomic, copy) NSString *notificationCallbackId;
30
30
  @property (nonatomic, retain) NSMutableArray *notificationStack;
31
+ @property (nonatomic, strong) NSString *clickCallbackId;
31
32
 
32
33
  + (AppICEPlugin*) appice;
33
34
 
@@ -89,7 +90,6 @@ static NSString* const AIHandleActionNotification = @"AIHandleActionNotification
89
90
  -(void)pushNotificationClicked:(CDVInvokedUrlCommand *)command;
90
91
  -(void)getDeepLinkURL:(CDVInvokedUrlCommand *)command;
91
92
 
92
- //new empty function
93
93
  -(void)isDeviceReady:(CDVInvokedUrlCommand *)command;
94
94
  - (void)getMessageCountForUserIds:(CDVInvokedUrlCommand*)command;
95
95
  - (void)getInboxMessagesForUserIds:(CDVInvokedUrlCommand*)command;
@@ -108,5 +108,15 @@ static NSString* const AIHandleActionNotification = @"AIHandleActionNotification
108
108
  - (void)getUserId:(CDVInvokedUrlCommand*)command;
109
109
  - (void)getUserForIds:(CDVInvokedUrlCommand*)command;
110
110
  - (void)getInboxMessageForId:(CDVInvokedUrlCommand*)command;
111
+
112
+ //INAPP STATES
113
+ - (void)resumeInApp:(CDVInvokedUrlCommand *)command;
114
+ - (void)suspendInApp:(CDVInvokedUrlCommand *)command;
115
+ - (void)discardInApp:(CDVInvokedUrlCommand *)command;
116
+ - (void)dismissInApp:(CDVInvokedUrlCommand *)command;
117
+
118
+ //INAPP CTA
119
+ - (void)sendClickCallback:(CDVInvokedUrlCommand *)command;
120
+
111
121
  @end
112
122
 
@@ -1198,7 +1198,9 @@ static NSDictionary *pendingDeeplink = nil;
1198
1198
  if(pushPayload)
1199
1199
  {
1200
1200
  NSError *error = nil;
1201
- NSData *payloadData = [NSJSONSerialization dataWithJSONObject:pushPayload
1201
+ NSMutableDictionary *payloadKey = [NSMutableDictionary dictionary];
1202
+ payloadKey[@"payload"] = pushPayload;
1203
+ NSData *payloadData = [NSJSONSerialization dataWithJSONObject:payloadKey
1202
1204
  options:kNilOptions
1203
1205
  error:&error];
1204
1206
  if (error) {
@@ -1213,7 +1215,7 @@ static NSDictionary *pendingDeeplink = nil;
1213
1215
  }
1214
1216
  NSLog(@"Deeplink Push :payloadString string: %@", payloadString);
1215
1217
 
1216
- NSString *js = [NSString stringWithFormat:@"pushNotificationClicked({'payload':'%@'});",payloadString];
1218
+ NSString *js = [NSString stringWithFormat:@"pushNotificationClicked(%@);", payloadString];
1217
1219
  [self.commandDelegate evalJs:js];
1218
1220
  }
1219
1221
  else{
@@ -1563,6 +1565,88 @@ static NSDictionary *pendingDeeplink = nil;
1563
1565
  }
1564
1566
  return [messageDictArray copy];
1565
1567
  }
1568
+
1569
+ // Resume InApp
1570
+ - (void)resumeInApp:(CDVInvokedUrlCommand *)command {
1571
+ [self.commandDelegate runInBackground:^{
1572
+ @try {
1573
+ [[appICE sharedInstance] resumeInApp];
1574
+ CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1575
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
1576
+ } @catch (NSException *e) {
1577
+ CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:e.reason];
1578
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
1579
+ }
1580
+ }];
1581
+ }
1582
+
1583
+ // Suspend InApp
1584
+ - (void)suspendInApp:(CDVInvokedUrlCommand *)command {
1585
+ [self.commandDelegate runInBackground:^{
1586
+ @try {
1587
+ // [[appICE sharedInstance] suspendInApp];
1588
+ /**NOTE: As suspendInApp is queing the INAPP ,calling discardInApp in suspendInApp function which will do NOTHING (not queue) Done as Android**/
1589
+ [[appICE sharedInstance] discardInApp];
1590
+ CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1591
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
1592
+ } @catch (NSException *e) {
1593
+ CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:e.reason];
1594
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
1595
+ }
1596
+ }];
1597
+ }
1598
+
1599
+ // Discard InApp
1600
+ - (void)discardInApp:(CDVInvokedUrlCommand *)command {
1601
+ [self.commandDelegate runInBackground:^{
1602
+ @try {
1603
+ [[appICE sharedInstance] discardInApp];
1604
+ CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1605
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
1606
+ } @catch (NSException *e) {
1607
+ CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:e.reason];
1608
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
1609
+ }
1610
+ }];
1611
+ }
1612
+
1613
+ // Dismiss InApp
1614
+ - (void)dismissInApp:(CDVInvokedUrlCommand *)command {
1615
+ [self.commandDelegate runInBackground:^{
1616
+ @try {
1617
+ [[appICE sharedInstance] dismissInApp];
1618
+ CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1619
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
1620
+ } @catch (NSException *e) {
1621
+ CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:e.reason];
1622
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
1623
+ }
1624
+ }];
1625
+ }
1626
+
1627
+ - (void)sendClickCallback:(CDVInvokedUrlCommand *)command {
1628
+ [self.commandDelegate runInBackground:^{
1629
+ // Store the callback ID to use later when the SDK triggers a click
1630
+ self.clickCallbackId = command.callbackId;
1631
+
1632
+ [[appICE sharedInstance] setClickCallback:^(NSDictionary *cData) {
1633
+ NSLog(@"Cordova Plugin: Received click callback %@", cData);
1634
+
1635
+ if (self.clickCallbackId != nil && cData != nil) {
1636
+ CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:cData];
1637
+ [result setKeepCallbackAsBool:YES]; // Keep callback for future events
1638
+ [self.commandDelegate sendPluginResult:result callbackId:self.clickCallbackId];
1639
+ }
1640
+ }];
1641
+
1642
+ // Initial response to JS to keep callback open
1643
+ CDVPluginResult *initialResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
1644
+ [initialResult setKeepCallbackAsBool:YES];
1645
+ [self.commandDelegate sendPluginResult:initialResult callbackId:command.callbackId];
1646
+ }];
1647
+ }
1648
+
1649
+
1566
1650
  @end
1567
1651
 
1568
1652
 
package/www/AppICE.js CHANGED
@@ -428,5 +428,25 @@ AppICE.prototype.scheduleCampaign = function (cmpid, dur, userId, success, erro
428
428
  cordova.exec(success, error, "AppICEPlugin", "synchronizeData", [{"timeout": timeout}]);
429
429
  };
430
430
 
431
+ AppICE.prototype.resumeInApp = function (success, error) {
432
+ cordova.exec(success, error, "AppICEPlugin", "resumeInApp", []);
433
+ };
434
+
435
+ AppICE.prototype.suspendInApp = function (success, error) {
436
+ cordova.exec(success, error, "AppICEPlugin", "suspendInApp", []);
437
+ };
438
+
439
+ AppICE.prototype.discardInApp = function (success, error) {
440
+ cordova.exec(success, error, "AppICEPlugin", "discardInApp", []);
441
+ };
442
+
443
+ AppICE.prototype.dismissInApp = function (success, error) {
444
+ cordova.exec(success, error, "AppICEPlugin", "dismissInApp", []);
445
+ };
446
+
447
+ AppICE.prototype.sendClickCallback = function (success, error) {
448
+ cordova.exec(success, error, "AppICEPlugin", "sendClickCallback", []);
449
+ };
450
+
431
451
  module.exports = new AppICE();
432
452
  });