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
* Fix: [Android] Updated CallKit incoming/outgoing name parameter resolution
43
43
* Fix: [Web] Notification actions working intermittently.
44
+
* 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
+29-22Lines changed: 29 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,50 +165,57 @@ 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.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.
172
170
173
171
Also, the twilio javascript SDK itself, `twilio.min.js` is needed.
174
172
175
-
To ensure proper/as intended setup:
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,
179
-
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.
180
180
181
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.');
196
-
}).catch((error) => {
197
-
console.warn('Error registering Twilio Service Worker: '+error.message+'. This prevents notifications from working natively');
198
-
});
199
-
});
200
-
}
201
-
</script>
191
+
window.addEventListener('load', function(ev) {
192
+
// Download main.dart.js
193
+
...
202
194
</body>
203
195
```
204
196
205
197
#### Web Considerations
206
198
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.
208
-
209
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.
210
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)_
211
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).
printDebug("Failed to initialise firebase $error");
62
+
});
63
+
64
64
} else {
65
65
// For Android, iOS - Firebase will search for google-services.json in android/app directory or GoogleService-Info.plist in ios/Runner directory respectively.
0 commit comments