cordova-plugin-appice 2.2.1 → 2.2.2
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/example/www/index.html +89 -52
- package/example/www/js/AppInboxMessage.js +58 -0
- package/example/www/js/index.js +580 -99
- package/package.json +1 -1
- package/plugin.xml +6 -5
- package/src/android/AppICEPlugin.java +567 -54
- package/src/ios/AppICEPlugin.h +17 -1
- package/src/ios/AppICEPlugin.m +384 -12
- package/www/AppICE.js +86 -3
package/example/www/js/index.js
CHANGED
|
@@ -1,116 +1,147 @@
|
|
|
1
1
|
|
|
2
2
|
document.addEventListener('deviceready', onDeviceReady, false);
|
|
3
3
|
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
console.log("testing " + type + " " + t1)
|
|
4
|
+
function fetchDeeplink(payload, type) {
|
|
5
|
+
console.log("Type:", type, "Payload:", JSON.stringify(payload));
|
|
7
6
|
|
|
7
|
+
// Example: Fetch and use 'eurl' from the payload's 'cdata' object
|
|
8
|
+
var eurl = payload['eurl']; // Extract 'eurl' from payload
|
|
9
|
+
console.log("eurl:", eurl);
|
|
8
10
|
|
|
11
|
+
AppICE.getDataForKey(payload, 'eurl', function (result) {
|
|
12
|
+
console.log('getDataForKey result:', result);
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
14
|
+
navigator.notification.alert(
|
|
15
|
+
result, // Message
|
|
16
|
+
alertDismissed, // Callback
|
|
17
|
+
'Notification EURL', // Title
|
|
18
|
+
'OK' // Button name
|
|
19
|
+
);
|
|
20
|
+
});
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
function alertDismissed() {
|
|
21
|
-
|
|
24
|
+
console.log('Alert dismissed');
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
function onDeviceReady() {
|
|
25
28
|
// Cordova is now initialized. Have fun!
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
function pushNotificationClicked(payload, type) {
|
|
35
|
-
console.log('in testing method');
|
|
36
|
-
//var t1 = JSON.stringify(payload);
|
|
37
|
-
var newPayload = payload['payload'];
|
|
38
|
-
console.log("testing " + type);
|
|
39
|
-
|
|
40
|
-
AppICE.getDataForKey(newPayload, 'eurl', function(result) {
|
|
41
|
-
console.log('result getDataForKey method' + result);
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
//isDeviceReady
|
|
47
|
-
document.addEventListener('resume', onResume, false);
|
|
48
|
-
// Function to handle app resuming to foreground
|
|
49
|
-
function onResume() {
|
|
50
|
-
console.log('Deeplink Push : App is now in the foreground');
|
|
51
|
-
// Handle tasks needed when app comes back to the foreground
|
|
52
|
-
AppICE.isDeviceReady(true,
|
|
53
|
-
function(success) {
|
|
54
|
-
console.log('Deeplink Push STATE 4: App is active, isDeviceReady success:', success);
|
|
55
|
-
},
|
|
56
|
-
function(error) { console.log('Deeplink Push STATE 4: App is active, isDeviceReady error:', error); }
|
|
29
|
+
AppICE.isDeviceReady(
|
|
30
|
+
function (success) {
|
|
31
|
+
console.log('isDeviceReady:', success);
|
|
32
|
+
},
|
|
33
|
+
function (error) {
|
|
34
|
+
console.log('isDeviceReady:', error);
|
|
35
|
+
}
|
|
57
36
|
);
|
|
58
|
-
|
|
59
|
-
|
|
37
|
+
console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
|
|
38
|
+
document.getElementById('deviceready').classList.add('ready');
|
|
39
|
+
document.addEventListener('pushNotificationClicked', function (e) {
|
|
40
|
+
console.log('Event received:', e);
|
|
41
|
+
var payload = e.payload;
|
|
42
|
+
console.log('Payload:', payload);
|
|
43
|
+
if (payload) {
|
|
44
|
+
fetchDeeplink(payload, "notificationCallback");
|
|
45
|
+
}
|
|
46
|
+
});
|
|
60
47
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
function onPause() {
|
|
64
|
-
console.log('Deeplink Push : App is now in the background');
|
|
65
|
-
// Here you can handle any tasks needed when app goes to the background
|
|
66
|
-
AppICE.isDeviceReady(false,
|
|
67
|
-
function(success) { console.log('Deeplink Push : App is inactive, isDeviceReady success:', success); },
|
|
68
|
-
function(error) { console.log('Deeplink Push : App is inactive, isDeviceReady error:', error); }
|
|
69
|
-
);
|
|
48
|
+
initializesdk()
|
|
49
|
+
onResume()
|
|
70
50
|
}
|
|
71
51
|
|
|
72
|
-
|
|
73
52
|
// initialize appice sdk
|
|
74
|
-
document.
|
|
53
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
54
|
+
document.getElementById("initsdk").addEventListener("click", initializesdk);
|
|
55
|
+
});
|
|
56
|
+
|
|
75
57
|
function initializesdk() {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
58
|
+
var certs = [];
|
|
59
|
+
// certs = ["assets/ai_android.pem"]; // This is for enabling SSL pinning, if no SSL certificates pass null
|
|
60
|
+
console.log("certs : ", certs);
|
|
61
|
+
|
|
62
|
+
AppICE.initSdk(
|
|
63
|
+
"5bebe93c25d705690ffbc758",
|
|
64
|
+
"9e9ec60197c8373a11ac15ce4dae80e973608ab2",
|
|
65
|
+
"d985715d1bb48942d36d5d08de3b6a8c",
|
|
66
|
+
"",
|
|
67
|
+
"US",
|
|
68
|
+
"https://a.appice.io",
|
|
69
|
+
certs,
|
|
70
|
+
function (success) {
|
|
71
|
+
console.log("init success", success);
|
|
72
|
+
},
|
|
73
|
+
function (error) {
|
|
74
|
+
console.log("init Failed", error);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
AppICE.setSessionTimeout(1800,
|
|
79
|
+
function (success) {
|
|
80
|
+
console.log("Session success " + success);
|
|
81
|
+
},
|
|
82
|
+
function (error) {
|
|
83
|
+
console.log("Session Failed " + error);
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
85
87
|
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
//=======================
|
|
90
|
+
// USER-PROFILE SETTING
|
|
91
|
+
//=======================
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
//set user id
|
|
94
|
+
document.getElementById("userid").addEventListener("click", userId);
|
|
95
|
+
function userId() {
|
|
96
|
+
const userIdInput = document.getElementById("userIdInput").value.trim();
|
|
97
|
+
if (!userIdInput) {
|
|
98
|
+
alert("Please enter a valid User ID.");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
98
101
|
|
|
102
|
+
const userId = [userIdInput];
|
|
103
|
+
AppICE.setUserId(userId,
|
|
104
|
+
function (success) {
|
|
105
|
+
alert("User ID set successfully!"+success);
|
|
106
|
+
},
|
|
107
|
+
function (error) {
|
|
108
|
+
alert("Failed to set User ID."+error);
|
|
109
|
+
}
|
|
110
|
+
);
|
|
99
111
|
}
|
|
100
112
|
|
|
101
|
-
//
|
|
102
|
-
document.getElementById("
|
|
103
|
-
function
|
|
104
|
-
|
|
113
|
+
//get user id
|
|
114
|
+
document.getElementById("getUserId").addEventListener("click", GetUserId);
|
|
115
|
+
function GetUserId() {
|
|
116
|
+
AppICE.getUserId(
|
|
117
|
+
function (success) {
|
|
118
|
+
alert("getUsetId Data : " + success);
|
|
119
|
+
}, function (error) {
|
|
120
|
+
console.log("get user id Failed", error);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
105
123
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
console.log("registerLifeCycle Failed", error);
|
|
110
|
-
});
|
|
124
|
+
//get UserId
|
|
125
|
+
document.getElementById("getUser").addEventListener("click", GetUser);
|
|
126
|
+
function GetUser() {
|
|
111
127
|
|
|
128
|
+
AppICE.synchronizeData(10,
|
|
129
|
+
function (success) {
|
|
130
|
+
console.log("synchronizeData success: ", success);
|
|
131
|
+
alert("synchronizeData status : " + success);
|
|
132
|
+
AppICE.getUser(
|
|
133
|
+
function (success) {
|
|
134
|
+
alert("getUset Data : " + success);
|
|
135
|
+
}, function (error) {
|
|
136
|
+
console.log("getUser called Failed", error);
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
function (error) {
|
|
140
|
+
console.error("synchronizeData Error : ", error);
|
|
141
|
+
});
|
|
112
142
|
}
|
|
113
143
|
|
|
144
|
+
|
|
114
145
|
//set user details
|
|
115
146
|
document.getElementById("userinfo").addEventListener("click", userinfo);
|
|
116
147
|
function userinfo() {
|
|
@@ -121,20 +152,470 @@ function userinfo() {
|
|
|
121
152
|
});
|
|
122
153
|
}
|
|
123
154
|
|
|
124
|
-
//get
|
|
125
|
-
document.getElementById("
|
|
155
|
+
//get event1
|
|
156
|
+
document.getElementById("event1").addEventListener("click", allevent);
|
|
126
157
|
function allevent() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
158
|
+
console.log("inside event1 method");
|
|
159
|
+
var dataObj = {
|
|
160
|
+
"ClickedMenuBtn": "false",
|
|
161
|
+
"CLickedSubmitBtn": "false",
|
|
162
|
+
"AppName": "event1"
|
|
163
|
+
};
|
|
164
|
+
AppICE.tagEvent("SampleApp", dataObj,
|
|
165
|
+
function (success) {
|
|
166
|
+
alert("tagEvent success: " + JSON.stringify(success));
|
|
167
|
+
|
|
168
|
+
}, function (error) {
|
|
169
|
+
console.error("tagEvent Error : " + error);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
//===============================
|
|
174
|
+
// Inbox APIS
|
|
175
|
+
//===============================
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Get inbox messages list.
|
|
179
|
+
*
|
|
180
|
+
* @param type the message type
|
|
181
|
+
* 1 = ALL
|
|
182
|
+
* 2 = UNREAD
|
|
183
|
+
* 3 = READ
|
|
184
|
+
* 4 = VIEWED
|
|
185
|
+
* 5 = DELETED
|
|
186
|
+
* @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
|
|
187
|
+
* @callback will have the string json array
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
document.getElementById("getInboxMessagesForUserIds").addEventListener("click", getInboxMessagesForUserIds);
|
|
191
|
+
|
|
192
|
+
function getInboxMessagesForUserIds() {
|
|
193
|
+
const userIdInput = document.getElementById("userIdInput").value.trim(); // Get input value
|
|
194
|
+
const type = document.getElementById("typeInput").value.trim();
|
|
195
|
+
|
|
196
|
+
if (!userIdInput) {
|
|
197
|
+
alert("Please enter a valid User ID.");
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const userId = [userIdInput];
|
|
202
|
+
|
|
203
|
+
AppICE.getInboxMessagesForUserIds(type, userId,
|
|
204
|
+
function (response) {
|
|
205
|
+
if (Array.isArray(response)) {
|
|
206
|
+
const appInboxMessages = response.map(item => new AppInboxMessage(item));
|
|
207
|
+
renderInboxMessages(appInboxMessages);
|
|
208
|
+
} else {
|
|
209
|
+
alert("Invalid response format. Check console for details.");
|
|
210
|
+
console.error("Response format issue:", response);
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
function (error) {
|
|
214
|
+
alert("Failed to fetch inbox messages. " + error);
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
document.getElementById("getInboxMessages").addEventListener("click", getInboxMessages);
|
|
220
|
+
function getInboxMessages() {
|
|
221
|
+
const type = document.getElementById("typeInput").value.trim();
|
|
222
|
+
if (!type) {
|
|
223
|
+
alert("Please enter message type");
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
AppICE.getInboxMessages(type,
|
|
228
|
+
function (response) {
|
|
229
|
+
if (Array.isArray(response)) {
|
|
230
|
+
const appInboxMessages = response.map(item => new AppInboxMessage(item));
|
|
231
|
+
renderInboxMessages(appInboxMessages);
|
|
232
|
+
} else {
|
|
233
|
+
alert("Invalid response format. Check console for details.");
|
|
234
|
+
console.error("Response format issue:", response);
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
function (error) {
|
|
238
|
+
alert("Failed to fetch inbox messages. " + error);
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
function renderInboxMessages(appInboxMessages) {
|
|
247
|
+
let inboxList = document.getElementById("inboxMessagesList");
|
|
248
|
+
|
|
249
|
+
if (!inboxList) {
|
|
250
|
+
inboxList = document.createElement("ul");
|
|
251
|
+
inboxList.id = "inboxMessagesList";
|
|
252
|
+
inboxList.style.padding = "0";
|
|
253
|
+
inboxList.style.margin = "0";
|
|
254
|
+
document.body.appendChild(inboxList);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
inboxList.innerHTML = "";
|
|
258
|
+
|
|
259
|
+
appInboxMessages.forEach((appInboxMessage) => {
|
|
260
|
+
|
|
261
|
+
getMediaDetails(appInboxMessage);
|
|
262
|
+
|
|
263
|
+
const listItem = document.createElement("li");
|
|
264
|
+
listItem.style.border = "1px solid #ddd";
|
|
265
|
+
listItem.style.margin = "10px";
|
|
266
|
+
listItem.style.padding = "10px";
|
|
267
|
+
listItem.style.listStyleType = "none";
|
|
268
|
+
|
|
269
|
+
listItem.innerHTML = `
|
|
270
|
+
<h3>${appInboxMessage.messageTitle}</h3>
|
|
271
|
+
<p><strong>Message ID:</strong> ${appInboxMessage.messageId}</p>
|
|
272
|
+
<p><strong>Campaign ID:</strong> ${appInboxMessage.messageCampid}</p>
|
|
273
|
+
<p><strong>Message Image:</strong> ${appInboxMessage.messageImage}</p>
|
|
274
|
+
<p><strong>Message Body:</strong> ${appInboxMessage.messageBody}</p>
|
|
275
|
+
<p><strong>Campaign Type:</strong> ${appInboxMessage.campType}</p>
|
|
276
|
+
<p><strong>Message Status:</strong> ${appInboxMessage.messageStatus}</p>
|
|
277
|
+
<p><strong>Message Language:</strong> ${appInboxMessage.messageLanguage}</p>
|
|
278
|
+
<p><strong>Custom Data:</strong> <pre>${JSON.stringify(appInboxMessage.customData, null, 2)}</pre></p>
|
|
279
|
+
<p><strong>Message Expiry Time:</strong> ${appInboxMessage.messageExpiryTime}</p>
|
|
280
|
+
<p><strong>Expanded Description:</strong> ${appInboxMessage.expandedDescription}</p>
|
|
281
|
+
<p><strong>Action Type:</strong> ${appInboxMessage.actionType}</p>
|
|
282
|
+
<p><strong>Action URL:</strong> <a href="${appInboxMessage.actionUrl}" target="_blank">${appInboxMessage.actionUrl}</a></p>
|
|
283
|
+
<h4>Actions:</h4>
|
|
284
|
+
`;
|
|
285
|
+
|
|
286
|
+
const actionList = document.createElement("ul");
|
|
287
|
+
appInboxMessage.actions.forEach((action, index) => {
|
|
288
|
+
const actionItem = document.createElement("li");
|
|
289
|
+
actionItem.style.listStyleType = "disc";
|
|
290
|
+
actionItem.innerHTML = `
|
|
291
|
+
<strong>Action ${index + 1}:</strong>
|
|
292
|
+
<p>Title: ${action.actionTitle}</p>
|
|
293
|
+
<p>Type: ${action.actionType}</p>
|
|
294
|
+
<p>URL: <a href="${action.actionUrl}" target="_blank">${action.actionUrl}</a></p>
|
|
295
|
+
<p>Reply Text: ${action.replyText}</p>
|
|
296
|
+
`;
|
|
297
|
+
actionList.appendChild(actionItem);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
listItem.appendChild(actionList);
|
|
301
|
+
inboxList.appendChild(listItem);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Function to get media details for a message
|
|
306
|
+
function getMediaDetails(appInboxMessagesRaw) {
|
|
307
|
+
// console.log("GETMEDIA inside getMediaDetails:", appInboxMessage);
|
|
308
|
+
const appInboxMessage = new AppInboxMediaData(appInboxMessagesRaw);
|
|
309
|
+
// Object to hold all collected data
|
|
310
|
+
let mediaData = "";
|
|
311
|
+
let mediaUrl = "";
|
|
312
|
+
let mediaType = "";
|
|
313
|
+
let mediaThumbnail = "";
|
|
314
|
+
|
|
315
|
+
AppICE.getMediaData(appInboxMessage, "imageUrl",
|
|
316
|
+
function (responseMediaData) {
|
|
317
|
+
mediaData = responseMediaData;
|
|
318
|
+
console.log("GETMEDIA getMediaData Correct:", JSON.stringify(mediaData, null, 2));
|
|
319
|
+
AppICE.getMediaUrl(appInboxMessage, mediaData,
|
|
320
|
+
function (responseMediaUrl) {
|
|
321
|
+
// assign media mediaUrl
|
|
322
|
+
mediaUrl = responseMediaUrl;
|
|
323
|
+
console.log("GETMEDIA getMediaUrl Correct:", responseMediaUrl);
|
|
324
|
+
},
|
|
325
|
+
function (error) {
|
|
326
|
+
console.error("GETMEDIA getMediaUrl Error:", error);
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
AppICE.getMediaType(appInboxMessage, mediaData,
|
|
331
|
+
function (responseMediaType) {
|
|
332
|
+
mediaType = responseMediaType;
|
|
333
|
+
console.log("GETMEDIA getMediaType Correct:", responseMediaType);
|
|
334
|
+
},
|
|
335
|
+
function (error) {
|
|
336
|
+
console.error("GETMEDIA getMediaType Error:", error);
|
|
337
|
+
}
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
AppICE.getMediaThumbnail(appInboxMessage, mediaData,
|
|
341
|
+
function (responseMediaThumbnail) {
|
|
342
|
+
mediaThumbnail = responseMediaThumbnail;
|
|
343
|
+
console.log("GETMEDIA getMediaThumbnail Correct:", responseMediaThumbnail);
|
|
344
|
+
if (mediaUrl) {
|
|
345
|
+
console.log("Complete Media Details:", JSON.stringify({
|
|
346
|
+
mediaData,
|
|
347
|
+
mediaUrl,
|
|
348
|
+
mediaType,
|
|
349
|
+
mediaThumbnail
|
|
350
|
+
}, null, 2));
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
function (error) {
|
|
354
|
+
console.error("GETMEDIA getMediaThumbnail Error:", error);
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
},
|
|
360
|
+
function (error) {
|
|
361
|
+
console.error("GETMEDIA getMediaData Error:", error);
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Get inbox messages count.
|
|
368
|
+
*
|
|
369
|
+
* @param type the message type is integer
|
|
370
|
+
* 1 = ALL
|
|
371
|
+
* 2 = UNREAD
|
|
372
|
+
* 3 = READ
|
|
373
|
+
* 4 = VIEWED
|
|
374
|
+
* 5 = DELETED
|
|
375
|
+
* @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
|
|
376
|
+
* @callback will have the integer
|
|
377
|
+
*/
|
|
378
|
+
document.getElementById("getMessageCountForUserIds").addEventListener("click", getMessageCountForUserIds);
|
|
379
|
+
function getMessageCountForUserIds() {
|
|
380
|
+
const type = document.getElementById("typeInput").value.trim();
|
|
381
|
+
const userIdInput = document.getElementById("userIdInput").value.trim();
|
|
382
|
+
const userId = [userIdInput];
|
|
383
|
+
|
|
384
|
+
if (!userIdInput) {
|
|
385
|
+
alert("Please enter a valid User ID.");
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
AppICE.getMessageCountForUserIds(type, userId,
|
|
390
|
+
function (success) {
|
|
391
|
+
console.log("getMessageCount success: ", success);
|
|
392
|
+
alert("getMessageCount : " + success);
|
|
393
|
+
},
|
|
394
|
+
function (error) {
|
|
395
|
+
console.error("getMessageCount Error : ", error);
|
|
396
|
+
});
|
|
140
397
|
}
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
document.getElementById("getMessageCount").addEventListener("click", getMessageCount);
|
|
401
|
+
function getMessageCount() {
|
|
402
|
+
const type = document.getElementById("typeInput").value.trim();
|
|
403
|
+
|
|
404
|
+
if (!type) {
|
|
405
|
+
alert("Please enter message type");
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
AppICE.getMessageCount(type,
|
|
410
|
+
function (success) {
|
|
411
|
+
console.log("getMessageCount success: ", success);
|
|
412
|
+
alert("getMessageCountWithType : " + success);
|
|
413
|
+
},
|
|
414
|
+
function (error) {
|
|
415
|
+
console.error("getMessageCountWithType Error : ", error);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Get messages payload based on message id.
|
|
421
|
+
*
|
|
422
|
+
* @param messageId - message id of the notification
|
|
423
|
+
* @param userId - single userid in string ie. "useridA"
|
|
424
|
+
* @callback will have the json object
|
|
425
|
+
*/
|
|
426
|
+
document.getElementById("getInboxMessageForIdWithUserId").addEventListener("click", getInboxMessageForIdWithUserId);
|
|
427
|
+
function getInboxMessageForIdWithUserId() {
|
|
428
|
+
const messageId = document.getElementById("msgId").value.trim();
|
|
429
|
+
const userIdInput = document.getElementById("userIdInput").value.trim();
|
|
430
|
+
if (!userIdInput || !messageId) {
|
|
431
|
+
alert("Please enter a valid User ID and Message Id To fetch Inbox Data");
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
AppICE.getInboxMessageForIdWithUserId(messageId, userIdInput,
|
|
436
|
+
function (inboxMessages) {
|
|
437
|
+
console.log("getInboxMessageForId success: ", JSON.stringify(inboxMessages));
|
|
438
|
+
const appInboxMessage = new AppInboxMessage(inboxMessages);
|
|
439
|
+
|
|
440
|
+
let messageDetails = `
|
|
441
|
+
Title: ${appInboxMessage.messageTitle}
|
|
442
|
+
Message ID: ${appInboxMessage.messageId}
|
|
443
|
+
Campaign ID: ${appInboxMessage.messageCampid}
|
|
444
|
+
Message Image: ${appInboxMessage.messageImage}
|
|
445
|
+
Message Body: ${appInboxMessage.messageBody}
|
|
446
|
+
Campaign Type: ${appInboxMessage.campType}
|
|
447
|
+
Status: ${appInboxMessage.messageStatus}
|
|
448
|
+
Language: ${appInboxMessage.messageLanguage}
|
|
449
|
+
Custom Data: ${JSON.stringify(appInboxMessage.customData, null, 2)}
|
|
450
|
+
Expiry Time: ${appInboxMessage.messageExpiryTime}
|
|
451
|
+
Expanded Description: ${appInboxMessage.expandedDescription}
|
|
452
|
+
Action Type: ${appInboxMessage.actionType}
|
|
453
|
+
Action URL: ${appInboxMessage.actionUrl}
|
|
454
|
+
Actions:
|
|
455
|
+
`;
|
|
456
|
+
|
|
457
|
+
// Loop through actions and append their details
|
|
458
|
+
appInboxMessage.actions.forEach((action, index) => {
|
|
459
|
+
messageDetails += `
|
|
460
|
+
Action ${index + 1}:
|
|
461
|
+
- Title: ${action.actionTitle}
|
|
462
|
+
- Type: ${action.actionType}
|
|
463
|
+
- URL: ${action.actionUrl}
|
|
464
|
+
- Reply Text: ${action.replyText}
|
|
465
|
+
`;
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// Show the alert
|
|
469
|
+
alert(messageDetails);
|
|
470
|
+
},
|
|
471
|
+
function (error) {
|
|
472
|
+
console.error("getInboxMessageForId Error : ", error);
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
document.getElementById("getInboxMessageForId").addEventListener("click", getInboxMessageForId);
|
|
478
|
+
function getInboxMessageForId() {
|
|
479
|
+
const messageId = document.getElementById("msgId").value.trim();
|
|
480
|
+
if (!messageId) {
|
|
481
|
+
alert("Please enter a valid Message Id To fetch Inbox Data");
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
AppICE.getInboxMessageForId(messageId,
|
|
486
|
+
function (inboxMessages) {
|
|
487
|
+
console.log("getInboxMessageForId success: ", JSON.stringify(inboxMessages));
|
|
488
|
+
const appInboxMessage = new AppInboxMessage(inboxMessages);
|
|
489
|
+
|
|
490
|
+
let messageDetails = `
|
|
491
|
+
Title: ${appInboxMessage.messageTitle}
|
|
492
|
+
Message ID: ${appInboxMessage.messageId}
|
|
493
|
+
Campaign ID: ${appInboxMessage.messageCampid}
|
|
494
|
+
Message Image: ${appInboxMessage.messageImage}
|
|
495
|
+
Message Body: ${appInboxMessage.messageBody}
|
|
496
|
+
Campaign Type: ${appInboxMessage.campType}
|
|
497
|
+
Status: ${appInboxMessage.messageStatus}
|
|
498
|
+
Language: ${appInboxMessage.messageLanguage}
|
|
499
|
+
Custom Data: ${JSON.stringify(appInboxMessage.customData, null, 2)}
|
|
500
|
+
Expiry Time: ${appInboxMessage.messageExpiryTime}
|
|
501
|
+
Expanded Description: ${appInboxMessage.expandedDescription}
|
|
502
|
+
Action Type: ${appInboxMessage.actionType}
|
|
503
|
+
Action URL: ${appInboxMessage.actionUrl}
|
|
504
|
+
Actions:
|
|
505
|
+
`;
|
|
506
|
+
|
|
507
|
+
// Loop through actions and append their details
|
|
508
|
+
appInboxMessage.actions.forEach((action, index) => {
|
|
509
|
+
messageDetails += `
|
|
510
|
+
Action ${index + 1}:
|
|
511
|
+
- Title: ${action.actionTitle}
|
|
512
|
+
- Type: ${action.actionType}
|
|
513
|
+
- URL: ${action.actionUrl}
|
|
514
|
+
- Reply Text: ${action.replyText}
|
|
515
|
+
`;
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
// Show the alert
|
|
519
|
+
alert(messageDetails);
|
|
520
|
+
},
|
|
521
|
+
function (error) {
|
|
522
|
+
console.error("getInboxMessageForId Error : ", error);
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* update message status ex. UNREAD to READ.
|
|
529
|
+
* 1 = ALL
|
|
530
|
+
* 2 = UNREAD
|
|
531
|
+
* 3 = READ
|
|
532
|
+
* 4 = VIEWED
|
|
533
|
+
* 5 = DELETED
|
|
534
|
+
* @param messageId - message id of the notification
|
|
535
|
+
* @param type - integer value for status
|
|
536
|
+
* @param userId - single userid in string
|
|
537
|
+
* @callback will have the boolean
|
|
538
|
+
*
|
|
539
|
+
*
|
|
540
|
+
*/
|
|
541
|
+
document.getElementById("updateInboxMessageForUserId").addEventListener("click", updateInboxMessageForUserId);
|
|
542
|
+
function updateInboxMessageForUserId() {
|
|
543
|
+
const type = document.getElementById("typeInput").value.trim();
|
|
544
|
+
const messageId = document.getElementById("msgId").value.trim();
|
|
545
|
+
const userIdInput = document.getElementById("userIdInput").value.trim();
|
|
546
|
+
if (!userIdInput || !messageId || !type) {
|
|
547
|
+
alert("Please enter a valid User ID, Message Id Camp id and Type to Update Inbox Data");
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
AppICE.updateInboxMessageForUserId(messageId, type, userIdInput,
|
|
552
|
+
function (success) {
|
|
553
|
+
alert("updateInboxMessage status : " + success);
|
|
554
|
+
},
|
|
555
|
+
function (error) {
|
|
556
|
+
console.error("updateInboxMessage Error : ", error);
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
document.getElementById("updateInboxMessage").addEventListener("click", updateInboxMessage);
|
|
561
|
+
function updateInboxMessage() {
|
|
562
|
+
const type = document.getElementById("typeInput").value.trim();
|
|
563
|
+
const messageId = document.getElementById("msgId").value.trim();
|
|
564
|
+
|
|
565
|
+
if (!messageId || !type) {
|
|
566
|
+
alert("Please enter Message Id and Type to Update Inbox Data");
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
AppICE.updateInboxMessage(messageId, type,
|
|
571
|
+
function (success) {
|
|
572
|
+
alert("updateInboxMessage status : " + success);
|
|
573
|
+
},
|
|
574
|
+
function (error) {
|
|
575
|
+
console.error("updateInboxMessage Error : ", error);
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
document.getElementById("synInbox").addEventListener("click", syncronizeInboxMessage);
|
|
581
|
+
function syncronizeInboxMessage() {
|
|
582
|
+
const userIdInput = document.getElementById("userIdInput").value.trim();
|
|
583
|
+
const userId = [userIdInput];
|
|
584
|
+
AppICE.synchronizeInbox(10,
|
|
585
|
+
function (success) {
|
|
586
|
+
console.log("syncronizeInboxMessage success: ", success);
|
|
587
|
+
alert("syncronizeInboxMessage status : " + success);
|
|
588
|
+
AppICE.getInboxMessage(1, userId,
|
|
589
|
+
function (inboxMessages) {
|
|
590
|
+
console.log("syncronizeInboxMessage success: " + JSON.stringify(inboxMessages));
|
|
591
|
+
}, function (error) {
|
|
592
|
+
console.error("syncronizeInboxMessage Error: ", error);
|
|
593
|
+
}
|
|
594
|
+
);
|
|
595
|
+
},
|
|
596
|
+
function (error) {
|
|
597
|
+
console.error("syncronizeInboxMessage Error : ", error);
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
document.getElementById("scheduleCampaign").addEventListener("click", scheduleCampaign);
|
|
602
|
+
function scheduleCampaign() {
|
|
603
|
+
const cmpid = document.getElementById("cmpid").value.trim();
|
|
604
|
+
const userIdInput = document.getElementById("userIdInput").value.trim();
|
|
605
|
+
const userId = [userIdInput];
|
|
606
|
+
if (!userIdInput || !cmpid) {
|
|
607
|
+
alert("Please enter a valid User ID and campaign ID");
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
AppICE.scheduleCampaign(cmpid, 60, userId,
|
|
612
|
+
function (success) {
|
|
613
|
+
alert("scheduleCampaign status : " + success);
|
|
614
|
+
},
|
|
615
|
+
function (error) {
|
|
616
|
+
console.error("scheduleCampaign Error : ", error);
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
|