pushwoosh-cordova-plugin 8.3.57 → 8.3.59

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,175 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
6
- <meta name="format-detection" content="telephone=no">
7
- <meta name="msapplication-tap-highlight" content="no">
8
- <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
9
- <meta name="color-scheme" content="light dark">
10
- <link rel="stylesheet" href="css/index.css">
11
- <title>Pushwoosh VoIP Demo</title>
12
- </head>
13
- <body>
14
- <!-- Welcome Screen -->
15
- <div id="welcomeScreen" class="welcome-overlay">
16
- <div class="welcome-content">
17
- <h2>Welcome to Pushwoosh VoIP Demo</h2>
18
- <div class="welcome-instructions">
19
- <p><strong>How to use this app:</strong></p>
20
- <ol>
21
- <li>Enter your App ID (VoIP App Code) and FCM Project ID</li>
22
- <li>Click "Initialize Pushwoosh" to start the SDK</li>
23
- <li>Initialize VoIP Parameters to configure video support and ringtone</li>
24
- <li>Request Call Permission on Android if needed</li>
25
- <li>Use End Call button to terminate active calls</li>
26
- <li>Monitor VoIP events in the Event Log below</li>
27
- </ol>
28
- <p><strong>Testing VoIP Calls:</strong></p>
29
- <p>To receive incoming VoIP calls, send a VoIP push notification from the Pushwoosh Control Panel using your App ID.</p>
30
- </div>
31
- <div class="welcome-footer">
32
- <label class="welcome-checkbox">
33
- <input type="checkbox" id="dontShowAgain">
34
- <span>Don't show this again</span>
35
- </label>
36
- <button id="btnGetStarted" class="btn btn-primary">Get Started</button>
37
- </div>
38
- </div>
39
- </div>
40
-
41
- <!-- Cancelled Call Modal -->
42
- <div id="cancelledCallModal" class="call-modal hidden">
43
- <div class="call-modal-content">
44
- <div class="call-modal-icon">📞</div>
45
- <h2>Call Cancelled</h2>
46
- <p class="call-modal-subtitle">The caller has ended the call</p>
47
- <div class="call-details">
48
- <div class="call-detail-item">
49
- <span class="call-detail-label">Caller:</span>
50
- <span id="cancelledCallerName" class="call-detail-value">Unknown</span>
51
- </div>
52
- <div class="call-detail-item">
53
- <span class="call-detail-label">Call ID:</span>
54
- <span id="cancelledCallId" class="call-detail-value">N/A</span>
55
- </div>
56
- <div class="call-detail-item">
57
- <span class="call-detail-label">Handle Type:</span>
58
- <span id="cancelledHandleType" class="call-detail-value">N/A</span>
59
- </div>
60
- <div class="call-detail-item">
61
- <span class="call-detail-label">Video:</span>
62
- <span id="cancelledHasVideo" class="call-detail-value">No</span>
63
- </div>
64
- </div>
65
- <button id="btnDismissCancelledCall" class="btn btn-primary">OK</button>
66
- </div>
67
- </div>
68
-
69
- <div class="app">
70
- <div class="scroll-content">
71
- <!-- Device Status -->
72
- <div id="deviceready" class="status-indicator">
73
- <div class="status listening">Connecting to Device...</div>
74
- <div class="status ready">Device Ready</div>
75
- </div>
76
-
77
- <!-- Push Notifications Setup Section -->
78
- <div class="section">
79
- <h2>Push Notifications Setup</h2>
80
-
81
- <div class="form-group">
82
- <label for="pushAppId">App ID / VoIP App Code</label>
83
- <input type="text" id="pushAppId" value="7BCDB-76CBE">
84
- </div>
85
-
86
- <div class="form-group">
87
- <label for="pushProjectId">FCM Project ID (Android)</label>
88
- <input type="text" id="pushProjectId" value="843884467752">
89
- </div>
90
-
91
- <button id="btnInitPushwoosh" class="btn btn-primary">Initialize Pushwoosh</button>
92
- </div>
93
-
94
- <!-- VoIP Parameters Section -->
95
- <div class="section">
96
- <h2>VoIP Parameters</h2>
97
-
98
- <div class="form-group">
99
- <label class="checkbox-label">
100
- <input type="checkbox" id="supportsVideo" checked>
101
- <span>Supports Video</span>
102
- </label>
103
- </div>
104
-
105
- <div class="form-group">
106
- <label for="ringtoneSound">Ringtone Sound</label>
107
- <input type="text" id="ringtoneSound" value="ring.caf" placeholder="ring.caf">
108
- </div>
109
-
110
- <div class="form-group">
111
- <label for="handleType">Handle Type</label>
112
- <select id="handleType">
113
- <option value="1">Generic - Generic handle type</option>
114
- <option value="2" selected>Phone Number - Phone number handle</option>
115
- <option value="3">Email Address - Email address handle</option>
116
- </select>
117
- </div>
118
-
119
- <button id="btnInitVoIP" class="btn btn-primary">Initialize VoIP Parameters</button>
120
- </div>
121
-
122
- <!-- Call Timeout Section -->
123
- <div class="section">
124
- <h2>Call Timeout</h2>
125
-
126
- <div class="form-group">
127
- <label for="callTimeout">Incoming Call Timeout (seconds)</label>
128
- <input type="text" id="callTimeout" value="30.0" placeholder="30.0">
129
- </div>
130
-
131
- <button id="btnSetCallTimeout" class="btn btn-primary">Set Call Timeout</button>
132
- </div>
133
-
134
- <!-- Call Permissions Section -->
135
- <div class="section">
136
- <h2>Call Permissions</h2>
137
- <button id="btnRequestCallPermission" class="btn btn-secondary">
138
- Request Call Permission (Android Only)
139
- </button>
140
- <button id="btnGetCallPermissionStatus" class="btn btn-secondary">
141
- Get Call Permission Status
142
- </button>
143
- <div id="permissionStatus" class="status-text"></div>
144
- </div>
145
-
146
- <!-- Push Notifications Registration Section -->
147
- <div class="section">
148
- <h2>Push Notifications</h2>
149
- <button id="btnRegisterPush" class="btn btn-secondary">
150
- Register for Push Notifications
151
- </button>
152
- <button id="btnGetNotificationStatus" class="btn btn-secondary">
153
- Get Notification Status
154
- </button>
155
- <div id="notificationStatus" class="status-text"></div>
156
- </div>
157
-
158
- <!-- Call Controls Section -->
159
- <div class="section">
160
- <h2>Call Controls</h2>
161
- <button id="btnEndCall" class="btn btn-danger">End Call</button>
162
- </div>
163
-
164
- <!-- VoIP Events Log Section -->
165
- <div class="section">
166
- <h2>VoIP Events Log</h2>
167
- <button id="btnClearLog" class="btn btn-small">Clear Log</button>
168
- <div id="eventLog" class="event-log"></div>
169
- </div>
170
- </div>
171
- </div>
172
- <script src="cordova.js"></script>
173
- <script src="js/index.js"></script>
174
- </body>
175
- </html>
@@ -1,419 +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
- document.addEventListener('deviceready', onDeviceReady, false);
21
-
22
- document.addEventListener('DOMContentLoaded', function() {
23
- checkAndShowWelcomeScreen();
24
- setupUIEventListeners();
25
- setupWelcomeScreen();
26
- });
27
-
28
- let pushwoosh = null;
29
-
30
- function checkAndShowWelcomeScreen() {
31
- const dontShowAgain = localStorage.getItem('dontShowWelcome');
32
- const welcomeScreen = document.getElementById('welcomeScreen');
33
-
34
- if (dontShowAgain === 'true') {
35
- welcomeScreen.classList.add('hidden');
36
- } else {
37
- welcomeScreen.classList.remove('hidden');
38
- }
39
- }
40
-
41
- function setupWelcomeScreen() {
42
- document.getElementById('btnGetStarted').addEventListener('click', function() {
43
- const dontShowCheckbox = document.getElementById('dontShowAgain');
44
-
45
- if (dontShowCheckbox.checked) {
46
- localStorage.setItem('dontShowWelcome', 'true');
47
- }
48
-
49
- document.getElementById('welcomeScreen').classList.add('hidden');
50
- });
51
- }
52
-
53
- // VoIP event names
54
- const VOIP_EVENTS = [
55
- 'voipPushPayload',
56
- 'answer',
57
- 'reject',
58
- 'hangup',
59
- 'muted',
60
- 'unmuted',
61
- 'held',
62
- 'unheld',
63
- 'dtmf',
64
- 'audioInterruption',
65
- 'callFailed',
66
- 'providerDidActivate',
67
- 'providerDidDeactivate',
68
- 'incomingCallSuccess',
69
- 'incomingCallFailure',
70
- 'playDTMF',
71
- 'voipDidFailToRegisterTokenWithError',
72
- 'voipDidRegisterTokenSuccessfully',
73
- 'voipDidCancelCall',
74
- 'voipDidFailToCancelCall'
75
- ];
76
-
77
- function onDeviceReady() {
78
- console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
79
- document.getElementById('deviceready').classList.add('ready');
80
-
81
- pushwoosh = cordova.require("pushwoosh-cordova-plugin.PushNotification");
82
-
83
- registerVoIPEvents();
84
-
85
- // Auto-initialize with default values
86
- const appId = document.getElementById('pushAppId').value;
87
- const projectId = document.getElementById('pushProjectId').value;
88
- if (appId) {
89
- initializePushwoosh(appId, projectId);
90
-
91
- // Auto-call registerDevice after initialization to test callbacks
92
- setTimeout(function() {
93
- pushwoosh.registerDevice(
94
- function(status) {
95
- var pushToken = status.pushToken;
96
- console.log('PUSH TOKEN +++++++++ : ' + pushToken);
97
- },
98
- function(status) {
99
- console.log('REGISTRATION ERROR: ' + JSON.stringify(status));
100
- }
101
- );
102
- }, 1000);
103
- }
104
- }
105
-
106
- function initializePushwoosh(appId, projectId) {
107
- console.log('Initializing Pushwoosh with App ID:', appId, 'Project ID:', projectId);
108
-
109
- // Initialize Pushwoosh
110
- pushwoosh.onDeviceReady({
111
- "appid": appId,
112
- "projectid": projectId || ""
113
- });
114
-
115
- pushwoosh.getPushToken(
116
- function(token) {
117
- console.log('Push Token:', token);
118
- }
119
- );
120
-
121
- pushwoosh.getPushwooshHWID(
122
- function(hwid) {
123
- console.log('HWID:', hwid);
124
- }
125
- );
126
- }
127
-
128
- function registerVoIPEvents() {
129
- VOIP_EVENTS.forEach(function(eventName) {
130
- pushwoosh.registerEvent(
131
- eventName,
132
- function(data) {
133
- console.log('====== VOIP EVENT CALLBACK TRIGGERED ======');
134
- console.log('EVENT NAME: ' + eventName);
135
- console.log('EVENT DATA: ' + JSON.stringify(data));
136
- console.log('===========================================');
137
- console.log('[VoIP Event] ' + eventName + ':', data);
138
- logEventToUI(eventName, JSON.stringify(data, null, 2));
139
-
140
- // Special handling for call cancellation
141
- if (eventName === 'voipDidCancelCall') {
142
- showCancelledCallModal(data);
143
- }
144
- },
145
- function(error) {
146
- console.error('Failed to register event ' + eventName + ':', error);
147
- }
148
- );
149
- });
150
- }
151
-
152
- function setupUIEventListeners() {
153
- // Initialize Pushwoosh button
154
- document.getElementById('btnInitPushwoosh').addEventListener('click', function() {
155
- const appId = document.getElementById('pushAppId').value;
156
- const projectId = document.getElementById('pushProjectId').value;
157
-
158
- if (!appId) {
159
- alert('Please enter App ID');
160
- return;
161
- }
162
-
163
- if (!pushwoosh) {
164
- alert('Pushwoosh not initialized yet. Wait for device ready.');
165
- return;
166
- }
167
-
168
- initializePushwoosh(appId, projectId);
169
- });
170
-
171
- // Initialize VoIP Parameters button
172
- document.getElementById('btnInitVoIP').addEventListener('click', function() {
173
- if (!pushwoosh) {
174
- alert('Pushwoosh not initialized yet. Wait for device ready.');
175
- return;
176
- }
177
- initializeVoIPParameters();
178
- });
179
-
180
- // Set Call Timeout button
181
- document.getElementById('btnSetCallTimeout').addEventListener('click', function() {
182
- if (!pushwoosh) {
183
- alert('Pushwoosh not initialized yet. Wait for device ready.');
184
- return;
185
- }
186
-
187
- const timeout = parseFloat(document.getElementById('callTimeout').value);
188
-
189
- if (isNaN(timeout) || timeout <= 0) {
190
- alert('Please enter a valid timeout value (greater than 0)');
191
- return;
192
- }
193
-
194
- pushwoosh.setIncomingCallTimeout(timeout);
195
- console.log('Call timeout set to:', timeout, 'seconds');
196
- alert('Incoming call timeout set to ' + timeout + ' seconds');
197
- });
198
-
199
- // Request Call Permission button (Android only)
200
- document.getElementById('btnRequestCallPermission').addEventListener('click', function() {
201
- if (!pushwoosh) {
202
- alert('Pushwoosh not initialized yet. Wait for device ready.');
203
- return;
204
- }
205
- pushwoosh.requestCallPermission(
206
- function(granted) {
207
- console.log('Call permission result: ' + (granted ? 'granted' : 'denied'));
208
- alert('Call permission ' + (granted ? 'granted' : 'denied'));
209
- },
210
- function(error) {
211
- console.error('Call permission error: ', error);
212
- alert('Call permission error: ' + error);
213
- }
214
- );
215
- });
216
-
217
- // Get Call Permission Status button
218
- document.getElementById('btnGetCallPermissionStatus').addEventListener('click', function() {
219
- if (!pushwoosh) {
220
- alert('Pushwoosh not initialized yet. Wait for device ready.');
221
- return;
222
- }
223
- pushwoosh.getCallPermissionStatus(
224
- function(status) {
225
- const statusText = 'Call Permission Status: ' + (status ? 'Granted' : 'Denied');
226
- document.getElementById('permissionStatus').textContent = statusText;
227
- console.log(statusText);
228
- },
229
- function(error) {
230
- const errorText = 'Error getting permission status: ' + error;
231
- document.getElementById('permissionStatus').textContent = errorText;
232
- console.log(errorText);
233
- }
234
- );
235
- });
236
-
237
- // Register for Push Notifications button
238
- document.getElementById('btnRegisterPush').addEventListener('click', function() {
239
- console.log('🔴 BUTTON CLICKED! btnRegisterPush was pressed');
240
- logEventToUI('🔴 Button clicked!', 'Button pressed');
241
-
242
- if (!pushwoosh) {
243
- console.log('⚠️ pushwoosh is null or undefined!');
244
- logEventToUI('ERROR', 'pushwoosh is null!');
245
- alert('Pushwoosh not initialized yet. Wait for device ready.');
246
- return;
247
- }
248
-
249
- console.log('🔵 Pushwoosh object:', pushwoosh);
250
- console.log('🔵 registerDevice type:', typeof pushwoosh.registerDevice);
251
- logEventToUI('DEBUG', 'pushwoosh object exists, registerDevice type: ' + typeof pushwoosh.registerDevice);
252
-
253
- if (!pushwoosh.registerDevice) {
254
- console.log('❌ registerDevice method does not exist!');
255
- logEventToUI('ERROR', 'registerDevice method does not exist!');
256
- return;
257
- }
258
-
259
- console.log('✅ About to call registerDevice...');
260
- logEventToUI('📱 registerDevice', 'Calling registerDevice with callbacks...');
261
-
262
- try {
263
- pushwoosh.registerDevice(
264
- function(status) {
265
- console.log('[CALLBACK TEST] ✅ SUCCESS CALLBACK FIRED!', status);
266
- logEventToUI('✅ SUCCESS callback', JSON.stringify(status, null, 2));
267
-
268
- var pushToken = status.pushToken;
269
- console.log('Push token received:', pushToken);
270
- alert('Successfully registered! Push token: ' + pushToken);
271
- },
272
- function(status) {
273
- console.log('[CALLBACK TEST] ❌ ERROR CALLBACK FIRED!', status);
274
- logEventToUI('❌ ERROR callback', JSON.stringify(status, null, 2));
275
- alert('Failed to register for push notifications: ' + JSON.stringify(status));
276
- }
277
- );
278
- console.log('✅ registerDevice call completed (call was made, waiting for callback...)');
279
- logEventToUI('✅ registerDevice called', 'Method invoked successfully, waiting for response...');
280
- } catch (e) {
281
- console.log('💥 EXCEPTION calling registerDevice:', e);
282
- logEventToUI('💥 EXCEPTION', 'Error: ' + e.message);
283
- }
284
-
285
- // Log after 3 seconds if no callback fired
286
- setTimeout(function() {
287
- console.log('[CALLBACK TEST] 3 seconds passed - checking if callbacks fired...');
288
- logEventToUI('⏰ 3 seconds passed', 'If no SUCCESS/ERROR callback above, callbacks did NOT fire!');
289
- }, 3000);
290
- });
291
-
292
- // Get Notification Status button
293
- document.getElementById('btnGetNotificationStatus').addEventListener('click', function() {
294
- if (!pushwoosh) {
295
- alert('Pushwoosh not initialized yet. Wait for device ready.');
296
- return;
297
- }
298
- pushwoosh.getRemoteNotificationStatus(
299
- function(status) {
300
- console.log('Notification status:', status);
301
-
302
- var statusText = 'Notification Status:\n';
303
- statusText += 'Enabled: ' + (status.enabled || '0') + '\n';
304
- statusText += 'Push Alert: ' + (status.pushAlert || '0') + '\n';
305
- statusText += 'Push Badge: ' + (status.pushBadge || '0') + '\n';
306
- statusText += 'Push Sound: ' + (status.pushSound || '0');
307
-
308
- if (status.time_sensitive_notifications !== undefined) {
309
- statusText += '\nTime Sensitive: ' + status.time_sensitive_notifications;
310
- }
311
- if (status.scheduled_summary !== undefined) {
312
- statusText += '\nScheduled Summary: ' + status.scheduled_summary;
313
- }
314
-
315
- document.getElementById('notificationStatus').textContent = statusText;
316
- logEventToUI('getRemoteNotificationStatus', JSON.stringify(status, null, 2));
317
- },
318
- function(error) {
319
- var errorText = 'Error getting notification status: ' + error;
320
- document.getElementById('notificationStatus').textContent = errorText;
321
- console.error(errorText);
322
- }
323
- );
324
- });
325
-
326
- // End Call button
327
- document.getElementById('btnEndCall').addEventListener('click', function() {
328
- if (!pushwoosh) {
329
- alert('Pushwoosh not initialized yet. Wait for device ready.');
330
- return;
331
- }
332
- pushwoosh.endCall(
333
- function() {
334
- console.log('Call ended successfully');
335
- },
336
- function(error) {
337
- console.log('Failed to end call: ' + error);
338
- }
339
- );
340
- });
341
-
342
- // Clear Log button
343
- document.getElementById('btnClearLog').addEventListener('click', function() {
344
- document.getElementById('eventLog').innerHTML = '';
345
- });
346
- }
347
-
348
- function initializeVoIPParameters() {
349
- const supportsVideo = document.getElementById('supportsVideo').checked;
350
- const ringtoneSound = document.getElementById('ringtoneSound').value;
351
- const handleType = parseInt(document.getElementById('handleType').value);
352
-
353
- console.log('Initializing VoIP with parameters:', {
354
- supportsVideo: supportsVideo,
355
- ringtoneSound: ringtoneSound,
356
- handleType: handleType
357
- });
358
-
359
- pushwoosh.initializeVoIPParameters(
360
- supportsVideo,
361
- ringtoneSound,
362
- handleType,
363
- function() {
364
- console.log('VoIP parameters initialized successfully');
365
- },
366
- function(error) {
367
- console.log('Failed to initialize VoIP parameters:', error);
368
- }
369
- );
370
- }
371
-
372
- function logEventToUI(eventName, data) {
373
- const timestamp = new Date().toLocaleTimeString();
374
-
375
- const eventLog = document.getElementById('eventLog');
376
- const logEntry = document.createElement('div');
377
- logEntry.className = 'log-entry';
378
-
379
- logEntry.innerHTML =
380
- '<span class="timestamp">[' + timestamp + ']</span>' +
381
- '<span class="event-name">' + eventName + '</span>' +
382
- '<br/>' +
383
- '<span class="event-data">' + (data || '') + '</span>';
384
-
385
- eventLog.insertBefore(logEntry, eventLog.firstChild);
386
-
387
- while (eventLog.children.length > 50) {
388
- eventLog.removeChild(eventLog.lastChild);
389
- }
390
- }
391
-
392
- function showCancelledCallModal(voipMessage) {
393
- const modal = document.getElementById('cancelledCallModal');
394
-
395
- // Map handle type to readable text
396
- const handleTypeMap = {
397
- 1: 'Generic',
398
- 2: 'Phone Number',
399
- 3: 'Email Address'
400
- };
401
-
402
- // Update modal content with call data
403
- document.getElementById('cancelledCallerName').textContent = voipMessage.callerName || 'Unknown';
404
- document.getElementById('cancelledCallId').textContent = voipMessage.callId || 'N/A';
405
- document.getElementById('cancelledHandleType').textContent = handleTypeMap[voipMessage.handleType] || 'Unknown';
406
- document.getElementById('cancelledHasVideo').textContent = voipMessage.hasVideo ? 'Yes' : 'No';
407
-
408
- // Show modal
409
- modal.classList.remove('hidden');
410
-
411
- // Setup dismiss button if not already done
412
- const dismissBtn = document.getElementById('btnDismissCancelledCall');
413
- if (!dismissBtn.hasListener) {
414
- dismissBtn.addEventListener('click', function() {
415
- modal.classList.add('hidden');
416
- });
417
- dismissBtn.hasListener = true;
418
- }
419
- }