|
1 | | -# web_callkit |
| 1 | +# web_callkit |
| 2 | + |
| 3 | +**This project is a Web Flutter plugin that facilitates handling of calls.** |
| 4 | + |
| 5 | +Inspired by the iOS CallKit framework, this plugin provides the boilerplate to manage calls via a |
| 6 | +simple API and provides a browser call control mechanism through browser notifications. |
| 7 | + |
| 8 | +### Notes |
| 9 | + |
| 10 | +Due to many voip providers e.g. twilio-voice.js providing their own SDKs and audio handling ( |
| 11 | +incoming ringing, etc), this plugin is intended to be used as a boilerplate for call management and |
| 12 | +not as a full-fledged voip solution. |
| 13 | + |
| 14 | +A bird's eye overview/usage of the plugin: |
| 15 | + |
| 16 | +- Notify callkit of an incoming call |
| 17 | +- Update state of call from VOIP/SIP provider |
| 18 | +- Add/update call capabilities (hold, mute, etc) |
| 19 | + |
| 20 | +## Features |
| 21 | + |
| 22 | +- Boilerplate for call management |
| 23 | +- Integration with browser notifications |
| 24 | +- Support background calls |
| 25 | +- Custom audio sounds for incoming calls, etc. |
| 26 | + |
| 27 | +### Call State flow |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +## Limitations |
| 32 | + |
| 33 | +### Browser notifications |
| 34 | + |
| 35 | +Use native browser integration, the following limitations apply to each platform. Usage of Flutter |
| 36 | +package [js_notifications](https://pub.dev/packages/js_notifications) is assist in browser |
| 37 | +notification integration to native systems. See [js_notifications > platform limitations](https://github.com/cybex-dev/js_notifications?tab=readme-ov-file#platform-limitations) |
| 38 | +for more information |
| 39 | + |
| 40 | +## Installation |
| 41 | + |
| 42 | +### Import the package |
| 43 | + |
| 44 | +```dart |
| 45 | +import 'package:web_callkit/web_callkit.dart'; |
| 46 | +``` |
| 47 | + |
| 48 | +### Display the system call screen |
| 49 | + |
| 50 | +Inform the plugin that an incoming call is being received. This will hook into the browser |
| 51 | +notification system. |
| 52 | + |
| 53 | +```dart |
| 54 | +WebCallKit.instance.displayIncomingCall( |
| 55 | +uuid: '1234', |
| 56 | +handle: 'John Doe', |
| 57 | +); |
| 58 | +``` |
| 59 | + |
| 60 | +### End the call |
| 61 | + |
| 62 | +End the call by calling the `endCall` method. This will remove the call screen and stop the browser |
| 63 | +notification. Calls are disconnected for various reasons, via local user requests or remote errors |
| 64 | +or disconnects with VoIP calls due to internet disruptions. |
| 65 | + |
| 66 | +The CallKit supports `DisconnectResponse` enum to specify the reason for the call disconnection. |
| 67 | + |
| 68 | +e.g. `WebCallKit.instance.reportCallDisconnected('1234', response: DisconnectResponse.local);` |
| 69 | + |
| 70 | +| Reason | Description | |
| 71 | +|----------|---------------------------------------------------------------------------------------| |
| 72 | +| local | Disconnect due to a local end call request. | |
| 73 | +| remote | Disconnect due to a remote end call request or remote party failed to answer in time. | |
| 74 | +| canceled | Disconnect due to a call was cancelled. | |
| 75 | +| missed | Disconnect due to a incoming call was not answered in time. | |
| 76 | +| rejected | Disconnect due to incoming call was rejected. | |
| 77 | +| busy | Disconnect due to remote party being busy. | |
| 78 | +| error | Disconnect due to an error. | |
| 79 | +| unknown | Disconnect response is unknown. | |
| 80 | + |
| 81 | +### Features |
| 82 | + |
| 83 | +#### Call Management |
| 84 | + |
| 85 | +CallKit provides a simple API to manage calls. The plugin provides methods to report incoming calls, |
| 86 | +end calls, and update call information. Futher, inspiration is taken from Android's ConnectionService |
| 87 | +providing a set of capabilities to manage calls, such as: |
| 88 | + |
| 89 | +| Reason | Description | |
| 90 | +|--------------|-------------------------------------------------------------| |
| 91 | +| hold | Ability to place a call on hold after the call has started. | |
| 92 | +| supportHold | Ability to place a call on hold from the start of the call. | |
| 93 | +| mute | Ability to mute a call. | |
| 94 | + |
| 95 | +##### Incoming Calls |
| 96 | + |
| 97 | +Incoming calls are displayed on the screen with the caller's name and number. The call screen can be |
| 98 | +customized with the caller's name, number, and profile picture. |
| 99 | + |
| 100 | +```dart |
| 101 | +WebCallKit.instance.reportNewCall( |
| 102 | +uuid: '1234', |
| 103 | +handle: 'John Doe', |
| 104 | +); |
| 105 | +``` |
| 106 | + |
| 107 | +#### Notification Integration |
| 108 | + |
| 109 | +#### Capabilities |
| 110 | + |
| 111 | +## Limitations / Future work |
| 112 | + |
| 113 | +- Support video & desktop streaming natively |
| 114 | + |
0 commit comments