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: README.md
+26-10Lines changed: 26 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,29 +165,28 @@ See [example](https://github.com/cybex-dev/twilio_voice/blob/master/example/andr
165
165
166
166
There are 4 important files for Twilio incoming/missed call notifications to work:
167
167
168
-
-`twilio.min.js` is the twilio javascript SDK, it is used to handle the incoming calls.
169
168
-`notifications.js` is the main file, it handles the notifications and the service worker.
170
-
-`load-sw.js` is responsible for (re)loading the twilio service worker.
171
-
-`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 (this can be found in `build/web/flutter_service_worker.js`). This file's contents are copied into the flutter service worker.
172
170
173
171
Also, the twilio javascript SDK itself, `twilio.min.js` is needed.
174
172
175
173
To ensure proper/as intended setup:
176
174
177
-
1. Locate 4 files (`twilio.min.js`, `load-sw.js`, `notifications.js` and `twilio-sw.js`) from `example/web` folder
178
-
2. Copy all 4 files into your own project,
175
+
1. Locate 3 files (`twilio.min.js`, `notifications.js` and `twilio-sw.js`) from `example/web` folder
176
+
2. Copy all 3 files into your own project,
179
177
3. (optional) Review & change the `notifications.js`, `twilio-sw.js` files to match your needs.
178
+
4. Build your application with `flutter build web` (or `flutter run -d chrome` to test locally), this will create a `build/web` folder.
179
+
5. Copy the content of `example/web/twilio-sw.js` into your `build/web/flutter_service_worker.js` file, **at the end of the file**.
180
180
181
181
Finally, add the following code to your `index.html` file, **at the end of body tag**:
@@ -204,11 +203,28 @@ Finally, add the following code to your `index.html` file, **at the end of body
204
203
205
204
#### Web Considerations
206
205
207
-
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.
206
+
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. Until such a time Flutter provides an appropriate mechanism to integrate with service workers, the suggested solution of post compilation merging of service workers is the best solution.
208
207
209
208
_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.
210
209
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)_
211
210
211
+
##### Service Worker
212
+
213
+
Unifying the service worker(s) is best done via post-compilation tools or a CI/CD pipeline (suggested).
214
+
215
+
A snippet of the suggested service worker integration is as follows:
216
+
217
+
```yaml
218
+
#...
219
+
- 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).
0 commit comments