@@ -34,9 +34,10 @@ The following describes the standard call flow expected of the `CallState` enum.
3434
3535### Browser notifications
3636
37- Use native browser integration, the following limitations apply to each platform. Usage of Flutter
38- package [ js_notifications] ( https://pub.dev/packages/js_notifications ) is assist in browser
39- notification integration to native systems.
37+ Use native browser integration, the following limitations apply to each platform.
38+
39+ Usage of Flutter package [ js_notifications] ( https://pub.dev/packages/js_notifications ) is assist in
40+ browser notification integration to native systems.
4041See [ js_notifications > platform limitations] ( https://github.com/cybex-dev/js_notifications?tab=readme-ov-file#platform-limitations )
4142for more information
4243
@@ -48,13 +49,36 @@ for more information
4849import 'package:web_callkit/web_callkit_web.dart';
4950```
5051
52+ ### Copy service worker
53+
54+ Copy the service worker file named ` js_notifications-sw.js ` from the ` example ` directory to your web
55+ directory. _ The name is very important, so make sure to have the file
56+ named ` js_notifications-sw.js ` ._
57+
58+ The folder structure should look like this:
59+
60+ ```
61+ your_project/
62+ ├── ...
63+ ├── lib/
64+ ├── web/
65+ │ ├── index.html
66+ │ ├── js_notifications-sw.js
67+ ```
68+
69+ ** Note:** This is required for the browser to handle notifications in the background. The service
70+ worker will handle incoming call notifications and display them even when the app is not in focus.
71+
5172### Display the system call screen
5273
5374Inform the plugin that an incoming call is being received. This will hook into the browser
5475notification system.
5576
5677``` dart
57- WebCallKitWeb.instance.displayIncomingCall(uuid: '1234',handle: 'John Doe',);
78+ WebCallKitWeb.instance.displayIncomingCall
79+ (
80+ uuid: '1234',handle: 'John Doe',
81+ );
5882```
5983
6084### End the call
@@ -92,7 +116,10 @@ Incoming calls are displayed on the screen with the caller's name and number. Th
92116customized with the caller's name, number, and profile picture.
93117
94118``` dart
95- WebCallKitWeb.instance.reportNewCall(uuid: '1234', handle: 'John Doe',);
119+ WebCallKitWeb.instance.reportNewCall
120+ (
121+ uuid: '1234', handle: 'John Doe',
122+ );
96123```
97124
98125##### End Calls
@@ -101,7 +128,14 @@ End calls by calling the `endCall` method. This will remove the call screen and
101128notification.
102129
103130``` dart
104- WebCallKitWeb.instance.reportCallDisconnected('1234', response:DisconnectResponse.local);
131+ WebCallKitWeb.instance.reportCallDisconnected
132+ ('1234
133+ '
134+ , response:
135+ DisconnectResponse
136+ .
137+ local
138+ );
105139```
106140
107141The response parameter is an enum of ` DisconnectResponse ` which specifies the reason for the call
@@ -123,7 +157,8 @@ The following described scenarios are valid DisconnectResponses for specific cal
123157| disconnecting | local, remote, unknown, error, |
124158| disconnected | local, remote, unknown, error, |
125159
126- if ` strictMode ` is enabled, the following valid ` DisconnectResponse ` s will be considered, else it will be rejected (and potentially thrown) in a future update.
160+ if ` strictMode ` is enabled, the following valid ` DisconnectResponse ` s will be considered, else it
161+ will be rejected (and potentially thrown) in a future update.
127162
128163#### Notification Integration
129164
@@ -147,7 +182,10 @@ The following describes the capabilities available:
147182The following provides an example of how to report call capabilities:
148183
149184``` dart
150- WebCallKitWeb.instance.reportCallCapabilities('1234', capabilities: [CallCapability.hold, CallCapability.mute]);
185+ WebCallKitWeb.instance.reportCallCapabilities
186+ ('1234
187+ '
188+ , capabilities: [CallCapability.hold, CallCapability.mute]);
151189```
152190
153191#### Call Actions
0 commit comments