You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+23-2Lines changed: 23 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,19 @@
1
1
## Next release
2
+
3
+
* Fix: [Web] Multiple missed call notifications
4
+
* Fix: [Android]`openPhoneAccountsSettings` not always opening on various Android (mainly Samsung) devices
5
+
6
+
## 0.1.0
7
+
2
8
* Feat: [Android] Turn off the screen when a call is active and the head is against the handset. @solid-software (https://solid.software)
3
9
* Feat: [macOS] Added support for macOS, based on iOS implementation backed by Twilio Voice Web (twilio-voice.js [v2.4.1-dev-custom](https://github.com/cybex-dev/twilio-voice.js/tree/2.4.1-dev-custom)).
4
10
* Feat: [Web] Web support with notifications (via Service Worker) with live example at https://twilio-voice-web.web.app@cybex-dev
* Fix: [Android] Updated CallKit incoming/outgoing name parameter resolution
48
+
* Fix: [Web] Notification actions working intermittently.
49
+
* Fix: [Web] Added suggested service worker integration with CI/CD unifying with `flutter_service_worker.js`, see [here](https://firebase.flutter.dev/docs/messaging/usage/#background-messages) for more info regarding service worker limitations.
Copy file name to clipboardExpand all lines: README.md
+60-26Lines changed: 60 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,49 +163,72 @@ See [example](https://github.com/cybex-dev/twilio_voice/blob/master/example/andr
163
163
164
164
### Web Setup:
165
165
166
-
There are 2 important files for Twilio incoming/missed call notifications to work:
166
+
There are 4 important files for Twilio incoming/missed call notifications to work:
167
167
168
168
-`notifications.js` is the main file, it handles the notifications and the service worker.
169
-
-`twilio-sw.js` is the service worker, it is used to handle the incoming calls.
169
+
-`twilio-sw.js` is the service worker_content_used to work with the default `flutter_service_worker.js` (this can be found in `build/web/flutter_service_worker.js` after calling `flutter build web`). This file's contents are to be copied into the `flutter_service_worker.js` file after you've built your application.
170
170
171
171
Also, the twilio javascript SDK itself, `twilio.min.js` is needed.
172
172
173
-
To ensure proper/as intended setup:
173
+
### To ensure proper/as intended setup:
174
174
175
-
1. Get all 3 files (`notifications.js`, `twilio.min.js` and `twilio-sw.js`) from `example/web` folder
176
-
2. Copy all 3 into your own project,
177
-
3. (optional) Review & change the `notifications.js`, `twilio-sw.js) files to match your needs.
175
+
1. Copy files `example/web/notifications.js` and `example/web/twilio.min.js` into your application's `web` folder.
176
+
2. This step should be done AFTER you've built your application, every time the `flutter_service_worker.js` changes (this includes hot reloads on your local machine unfortunately)
177
+
1. Copy the contents of `example/web/twilio-sw.js` into your `build/web/flutter_service_worker.js` file, **at the end of the file**. See [service-worker](#service-worker) for more information.
178
+
179
+
Note, these files can be changed to suite your needs - however the core functionality should remain the same: responding to `notificationclick`, `notificationclose`, `message` events and associated sub-functions.
178
180
179
181
Finally, add the following code to your `index.html` file, **at the end of body tag**:
console.log('Twilio Voice Service worker registered successfully.');
193
-
}).catch((error) => {
194
-
console.warn('Error registering Twilio Service Worker: '+error.message+'. This prevents notifications from working natively');
195
-
});
196
-
});
197
-
}
198
-
</script>
191
+
window.addEventListener('load', function(ev) {
192
+
// Download main.dart.js
193
+
...
199
194
</body>
200
195
```
201
196
202
197
#### Web Considerations
203
198
204
-
Notice should be given to using `firebase-messaging-sw.js` in addition to `twilio-sw.js` since these may cause conflict in service worker events being handled.
205
-
206
199
_If you need to debug the service worker, open up Chrome Devtools, go to Application tab, and select Service Workers from the left menu. There you can see the service workers and their status.
207
200
To review service worker `notificationclick`, `notificationclose`, `message`, etc events - do this using Chrome Devtools (Sources tab, left panel below 'site code' the service workers are listed)_
208
201
202
+
##### Service Worker
203
+
204
+
Unifying the service worker(s) is best done via post-compilation tools or a CI/CD pipeline (suggested).
205
+
206
+
A snippet of the suggested service worker integration is as follows:
207
+
208
+
```yaml
209
+
#...
210
+
- run: cd ./example; flutter build web --release --target=lib/main.dart--output=build/web
A complete example could be found in the github workflows `.github/workflows/flutter.yml` file, see [here](https://github.com/cybex-dev/twilio_voice/blob/master/.github/workflows/flutter.yml).
218
+
219
+
##### Web Notifications
220
+
221
+
2 types of notifications are shown:
222
+
- Incoming call notifications with 2 buttons: `Answer` and `Reject`,
223
+
- Missed call notifications with 1 button: `Call back`.
224
+
225
+
Notifications are presented as **alerts**. These notifications may not always been shown, check:
226
+
- if the browser supports notifications,
227
+
- if the user has granted permissions to show notifications,
228
+
- if the notifications display method / notifications is enabled by the system (e.g. macOS notifications are disabled, or Windows notifications are disabled, etc).
229
+
- if there are already notifications shown (https://stackoverflow.com/a/36383155/4628115)
230
+
- if system is in 'Do Not Disturb' or 'Focus' mode.
231
+
209
232
### MacOS Setup:
210
233
211
234
The plugin is essentially a [WKWebView](https://developer.apple.com/documentation/webkit/wkwebview)
@@ -332,12 +355,23 @@ Caller is usually referred to as `call.from` or `callInvite.from`. This can eith
332
355
333
356
The following rules are applied to determine the caller/recipient name, which is shown in the call screen and heads-up notification:
334
357
335
-
- If the caller is empty/not provided, the default caller name is shown e.g. "Unknown Caller", else
336
-
- if the caller is a number, the plugin will show the number as is, else
337
-
- if the caller is a string, the plugin will interpret the string as follows:
338
-
- if the `__TWI_CALLER_NAME` parameter is provided, the plugin will show the value of `__TWI_CALLER_NAME` as is, else
339
-
- if the `__TWI_CALLER_ID` parameter is provided, the plugin will search for a registered client with the same id and show the client name, else
340
-
- if not found or not provided, the plugin will search for a registered client with the `call.from` value and show the client name, as a last resort
- if the call is an CallInvite (incoming), the plugin will interpret the string as follows or if the call is outgoing, the twilio `To` parameter field is used to:
370
+
- if the `__TWI_CALLER_NAME` (or `__TWI_RECIPIENT_NAME`) parameter is provided, the plugin will show the value of `__TWI_CALLER_NAME` (or `__TWI_RECIPIENT_NAME`) as is, else
371
+
- if the `__TWI_CALLER_ID` (or `__TWI_RECIPIENT_ID`) parameter is provided, the plugin will search for a registered client with the same id and show the client name,
372
+
- if the caller (`from` or `to` fields) is empty/not provided, the default caller name is shown e.g. "Unknown Caller", else
373
+
- else if the caller (`from` or `to` fields) is a number, the plugin will show the number as is, else
374
+
- else the plugin will search for a registered client with the `callInvite.from` (or call.to) value and show the client name, as a last resort
341
375
- the default caller name is shown e.g. "Unknown Caller"
342
376
343
377
*Please note: the same approach applies to both caller and recipient name resolution.*
0 commit comments