pushwoosh-cordova-plugin 8.3.41 → 8.3.42

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.
@@ -1,460 +0,0 @@
1
- /*
2
- * Licensed to the Apache Software Foundation (ASF) under one
3
- * or more contributor license agreements. See the NOTICE file
4
- * distributed with this work for additional information
5
- * regarding copyright ownership. The ASF licenses this file
6
- * to you under the Apache License, Version 2.0 (the
7
- * "License"); you may not use this file except in compliance
8
- * with the License. You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing,
13
- * software distributed under the License is distributed on an
14
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- * KIND, either express or implied. See the License for the
16
- * specific language governing permissions and limitations
17
- * under the License.
18
- */
19
-
20
- // Wait for the deviceready event before using any of Cordova's device APIs.
21
- // See https://cordova.apache.org/docs/en/latest/cordova/events/events.html#deviceready
22
- document.addEventListener('deviceready', onDeviceReady, false);
23
-
24
- function onDeviceReady() {
25
- var pushwoosh = cordova.require("pushwoosh-cordova-plugin.PushNotification");
26
-
27
- console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
28
- document.getElementById('deviceready').classList.add('ready');
29
-
30
- pushwooshInitialize(pushwoosh);
31
-
32
- pushwoosh.setVoipAppCode("7BCDB-76CBE");
33
- pushwoosh.initializeVoIPParameters(true, "ring.caf", 2, function(success) {
34
- console.log("Success:", success);
35
- }, function(error) {
36
- console.error("Error:", error);
37
- });
38
-
39
-
40
- pushwoosh.requestCallPermission();
41
- pushwoosh.registerEvent("answer",
42
- function(payload){
43
- console.log("Answer call from " + payload.callerName);
44
- },
45
- function(error) {
46
- console.log("ERROR");
47
-
48
- }
49
- );
50
-
51
- pushwoosh.registerEvent("reject",
52
- function(payload){
53
- console.log("Reject call from " + payload.callerName);
54
- },
55
- function(error) {
56
- console.log("ERROR");
57
-
58
- }
59
- );
60
-
61
- pushwoosh.registerEvent("hangup",
62
- function(payload){
63
- console.log("Reject call from " + payload.callerName);
64
- },
65
- function(error) {
66
- console.log("ERROR");
67
-
68
- }
69
- );
70
-
71
- pushwoosh.registerEvent("voipPushPayload",
72
- function(payload){
73
- console.log("Received call with " + JSON.stringify(payload));
74
- },
75
- function(error) {
76
- console.log("ERROR");
77
-
78
- }
79
- );
80
-
81
- registerForPushNotificationAction(pushwoosh);
82
-
83
- setTagsAction(pushwoosh);
84
- endCallAction(pushwoosh);
85
- setLanguageAction(pushwoosh);
86
- setUserIdAction(pushwoosh);
87
- sendPostEventAction(pushwoosh);
88
-
89
- getTagsAction(pushwoosh);
90
- getPushTokenAction(pushwoosh);
91
- getPushwooshHWIDAction(pushwoosh);
92
-
93
- sendLocalNotificationAction(pushwoosh);
94
- clearNotificationCenterAction(pushwoosh);
95
- }
96
-
97
- function endCallAction(pushwoosh) {
98
- document.getElementById('endCall').addEventListener('click', function() {
99
- pushwoosh.endCall(
100
- function() {
101
- console.warn('setTags success');
102
- },
103
- function(error) {
104
- console.warn('setTags failed');
105
- });
106
- });
107
- }
108
-
109
- function setTagsAction(pushwoosh) {
110
- document.getElementById('setTags').addEventListener('click', function() {
111
- var key = document.getElementById("textField1").value;
112
- var value = document.getElementById("textField2").value;
113
- /**
114
- * Function: setTags
115
- * [android, ios, wp8, windows] Set tags for the device
116
- *
117
- * Parameters:
118
- * "config" - object with custom device tags
119
- * "success" - success callback
120
- * "fail" - error callback
121
- *
122
- * | |
123
- * | |
124
- * __| |__
125
- * \ /
126
- * \ /
127
- * \ /
128
- * \__/
129
- */
130
- pushwoosh.setTags({key: key, value: value},
131
- function() {
132
- console.warn('setTags success');
133
- },
134
- function(error) {
135
- console.warn('setTags failed');
136
- })
137
- });
138
- }
139
-
140
- function setLanguageAction(pushwoosh) {
141
- document.getElementById('setLangBtn').addEventListener('click', function() {
142
- var language = document.getElementById('textField3').value;
143
-
144
- /**
145
- * [android, ios] Set custom application language (as opposed to the default system language).
146
- * This allows sending localized push messages
147
- *
148
- * Parameters:
149
- * "language" - string containing language code, i.e. "en", "fr"
150
- * | |
151
- * | |
152
- * __| |__
153
- * \ /
154
- * \ /
155
- * \ /
156
- * \__/
157
- */
158
- pushwoosh.setLanguage(language);
159
- });
160
- }
161
-
162
- function setUserIdAction(pushwoosh) {
163
- document.getElementById('setUserBtn').addEventListener('click', function() {
164
- var userId = document.getElementById('textField4').value;
165
-
166
- /**
167
- * Function: setUserId
168
- * [android, ios] Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
169
- * This allows data and events to be matched across multiple user devices.
170
- *
171
- * Parameters:
172
- * "userId" - user string identifier
173
- *
174
- * | |
175
- * | |
176
- * __| |__
177
- * \ /
178
- * \ /
179
- * \ /
180
- * \__/
181
- */
182
- pushwoosh.setUserId(userId);
183
- });
184
- }
185
-
186
- function sendPostEventAction(pushwoosh) {
187
- document.getElementById('setPostEventBtn').addEventListener('click', function() {
188
- var eventName = document.getElementById("textField5").value;
189
-
190
- /**
191
- * Function: postEvent
192
- * [android, ios] Post events for In-App Messages. This can trigger In-App message display as specified in Pushwoosh Control Panel.
193
- *
194
- * Parameters:
195
- * "event" - event to trigger
196
- * "attributes" - object with additional event attributes
197
- *
198
- * | |
199
- * | |
200
- * __| |__
201
- * \ /
202
- * \ /
203
- * \ /
204
- * \__/
205
- */
206
-
207
- pushwoosh.postEvent(eventName, { "buttonNumber" : 4, "buttonLabel" : "banner" });
208
- });
209
- }
210
-
211
- function getTagsAction(pushwoosh) {
212
- document.getElementById('getTags').addEventListener('click', function() {
213
- /**
214
- * Function: getTags
215
- * [android, ios, wp8, windows] Returns tags for the device including default tags
216
- *
217
- * Parameters:
218
- * "success" - success callback. Receives tags as parameter
219
- * "fail" - error callback
220
- * | |
221
- * | |
222
- * __| |__
223
- * \ /
224
- * \ /
225
- * \ /
226
- * \__/
227
- */
228
- pushwoosh.getTags(
229
- function(tags) {
230
- console.log('tags for device: ' + JSON.stringify(tags));
231
- },
232
- function(error) {
233
- console.log('get tags error: ' + JSON.stringify(error));
234
- }
235
- );
236
- }, false);
237
- }
238
-
239
- function getPushTokenAction(pushwoosh) {
240
- document.getElementById('getPushToken').addEventListener('click', function() {
241
-
242
- /**
243
- * Function: getPushToken
244
- * [android, ios, wp8, windows] Returns push token if it is available. Note the token also comes in registerDevice function callback.
245
- *
246
- * Parameters:
247
- * "success" - getPushToken callback
248
- *
249
- * | |
250
- * | |
251
- * __| |__
252
- * \ /
253
- * \ /
254
- * \ /
255
- * \__/
256
- */
257
- pushwoosh.getPushToken(
258
- function(token) {
259
- console.log('push token: ', + token);
260
- }
261
- );
262
- }, false);
263
- }
264
-
265
- function getPushwooshHWIDAction(pushwoosh) {
266
- document.getElementById('getHwid').addEventListener('click', function() {
267
-
268
- /**
269
- * Function: getPushwooshHWID
270
- * [android, ios, wp8, windows] Returns Pushwoosh HWID used for communications with Pushwoosh API
271
- *
272
- * Parameters:
273
- * "success" - getPushwooshHWID callback
274
- *
275
- * | |
276
- * | |
277
- * __| |__
278
- * \ /
279
- * \ /
280
- * \ /
281
- * \__/
282
- */
283
- pushwoosh.getPushwooshHWID(
284
- function(token) {
285
- console.log('Pushwoosh HWID: ' + token);
286
- }
287
- );
288
- });
289
- }
290
-
291
- function resetBadges(pushwoosh) {
292
- document.getElementById('resetBadges').addEventListener('click', function() {
293
-
294
- /**
295
- * Function: setApplicationIconBadgeNumber
296
- * [android, ios, wp8, windows] Set the application icon badge number
297
- *
298
- * Parameters:
299
- * "badgeNumber" - icon badge number
300
- *
301
- * | |
302
- * | |
303
- * __| |__
304
- * \ /
305
- * \ /
306
- * \ /
307
- * \__/
308
- */
309
-
310
- pushwoosh.setApplicationIconBadgeNumber('0');
311
- });
312
- }
313
-
314
- function sendLocalNotificationAction(pushwoosh) {
315
- document.getElementById('localNotification').addEventListener('click', function() {
316
-
317
- /**
318
- * Function: createLocalNotification
319
- * [android, ios] Schedules local notification.
320
- *
321
- * Parameters:
322
- * "config.msg" - notification message
323
- * "config.seconds" - notification delay in seconds
324
- * "config.userData" - addition data to pass in notification
325
- * "success" - success callback
326
- * "fail" - error callback
327
- *
328
- * | |
329
- * | |
330
- * __| |__
331
- * \ /
332
- * \ /
333
- * \ /
334
- * \__/
335
- */
336
-
337
- pushwoosh.createLocalNotification({msg: 'Hello, Pushwoosh!', seconds: 5, userData: 'optional'});
338
- });
339
- }
340
-
341
- function clearNotificationCenterAction(pushwoosh) {
342
- document.getElementById('clearNotificationCenter').addEventListener('click', function() {
343
-
344
- /**
345
- * Function: cancelAllLocalNotifications
346
- * [ios] Clears all notifications from the notification center
347
- *
348
- * | |
349
- * | |
350
- * __| |__
351
- * \ /
352
- * \ /
353
- * \ /
354
- * \__/
355
- */
356
-
357
- pushwoosh.cancelAllLocalNotifications();
358
- });
359
- }
360
-
361
- function registerForPushNotificationAction(pushwoosh) {
362
- var switcher = document.getElementById("switcher");
363
-
364
- switcher.addEventListener("change", function () {
365
- // Register for Push Notifications
366
- if (this.checked) {
367
-
368
- /**
369
- * Function: registerDevice
370
- * [android, ios, wp8, windows] Register device for push notifications and retreive a push Token
371
- *
372
- * Parameters:
373
- * "success" - success callback. Push token is passed as "status.pushToken" parameter to this callback
374
- * "fail" - error callback
375
- *
376
- * | |
377
- * | |
378
- * __| |__
379
- * \ /
380
- * \ /
381
- * \ /
382
- * \__/
383
- */
384
-
385
- pushwoosh.registerDevice(
386
- function (status) {
387
- var pushToken = status.pushToken;
388
- // Handle successful registration here
389
- console.log('Push token received: ', pushToken);
390
- },
391
- function (status) {
392
- // Handle registration error here
393
- console.error('Push registration failed: ', status);
394
- }
395
- );
396
- } else {
397
-
398
- /**
399
- * Function: unregisterDevice
400
- * [android, ios, wp8, windows] Unregister device form receiving push notifications
401
- *
402
- * Parameters:
403
- * "success" - success callback
404
- * "fail" - error callback
405
- *
406
- * | |
407
- * | |
408
- * __| |__
409
- * \ /
410
- * \ /
411
- * \ /
412
- * \__/
413
- */
414
-
415
- pushwoosh.unregisterDevice(
416
- function (status) {
417
- console.log('Success', status);
418
- },
419
- function (status) {
420
- console.error('Fail', status);
421
- }
422
- );
423
- }
424
- });
425
- }
426
-
427
- function pushwooshInitialize(pushwoosh) {
428
- // Should be called before pushwoosh.onDeviceReady
429
- document.addEventListener('push-notification', function (event) {
430
- var notification = event.notification;
431
- // Handle push open here
432
- console.log('Received push notification: ', notification);
433
- });
434
-
435
- /**
436
- * Function: onDeviceReady
437
- * [android, ios, wp8, windows] Initialize Pushwoosh plugin and trigger a start push message
438
- * Should be called on every app launch
439
- *
440
- * Parameters:
441
- * "config.appid" - Pushwoosh application code
442
- * "config.projectid" - GCM project number for android platform
443
- * "config.serviceName" - MPNS service name for wp8 platform
444
- *
445
- * initialize Pushwoosh with projectid:
446
- * "GOOGLE_PROJECT_NUMBER", appid : "PUSHWOOSH_APP_ID", serviceName : "WINDOWS_PHONE_SERVICE".
447
- * This will trigger all pending push notifications on start.
448
- * | |
449
- * | |
450
- * __| |__
451
- * \ /
452
- * \ /
453
- * \ /
454
- * \__/
455
- */
456
- pushwoosh.onDeviceReady({
457
- appid: "11C10-EF18D",
458
- projectid: "245850018966"
459
- });
460
- }