@@ -5,15 +5,18 @@ Flutter SDK for CallKit integration to Flutter applications on iOS
55Supported on iOS >= 10
66
77## Install
8+
891 . Add ` flutter_callkit_voximplant ` as a dependency in your pubspec.yaml file.
910
10112 . Add the following entry to your ` Info.plist ` file, located in ` <project root>/ios/Runner/Info.plist ` :
11- ```
12+
13+ ``` PLIST
1214<key>UIBackgroundModes</key>
1315<array>
14- <string>voip</string>
16+ <string>voip</string>
1517</array>
1618```
19+
1720This entry required for CallKit to work
1821
1922## Usage
@@ -31,7 +34,8 @@ A few differences explained:
3134- Use FCXPlugin.processPushCompletion (dart) to execute completion block received from push (iOS 11+ only)
3235- FCXCallController and FCXProvider are only allowed in single instance (use it as a singletone)
3336
34- #### Initialization
37+ ### Initialization
38+
3539``` dart
3640import 'package:flutter_callkit_voximplant/flutter_callkit_voximplant.dart';
3741
5054}
5155```
5256
53- #### Making outgoing calls
57+ ### Making outgoing calls
58+
5459To make an outgoing call, an app requests a FCXStartCallAction object from its FCXCallController object.
5560The action consists of a UUID to uniquely identify the call and a FCXHandle object to specify the recipient.
61+
5662``` dart
5763Future<void> makeCall(String contactName, String uuid) async {
5864 FCXHandle handle = FCXHandle(FCXHandleType.Generic, contactName);
@@ -61,18 +67,17 @@ Future<void> makeCall(String contactName, String uuid) async {
6167}
6268```
6369
64- After the recipient answers the call, the system calls the provider's performAnswerCallAction method.
65- In your implementation of that method, configure an AVAudioSession and call the fulfill() method
66- on the action object when finished.
70+ After the call is connected, the system calls the provider's performStartCallAction method. In your implementation,
71+ this method is responsible for configuring an AVAudioSession and calling fulfill() on the action when finished.
6772
6873``` dart
69- _provider.performAnswerCallAction = (answerCallAction ) async {
74+ _provider.performStartCallAction = (startCallAction ) async {
7075 // configure audio session
71- await answerCallAction .fulfill();
76+ await startCallAction .fulfill();
7277};
7378```
7479
75- #### Receiving an Incoming Call
80+ ### Receiving an Incoming Call
7681
7782Using the information provided by the external notification,
7883the app creates a UUID and a CXCallUpdate object to uniquely identify the call and the caller,
@@ -85,18 +90,18 @@ Future<void> handleIncomingCall(String contactName, String uuid) async {
8590}
8691```
8792
88- After the call is connected , the system calls the performStartCallAction method of the provider.
89- In your implementation, this method responsible for configuring an AVAudioSession
90- and calling fulfill() on the action when finished.
93+ After the recipient answers the call , the system calls the performAnswerCallAction method of the provider.
94+ In your implementation of that method, configure an AVAudioSession and call the fulfill() method
95+ on the action object when finished.
9196
9297``` dart
93- _provider.performStartCallAction = (startCallAction ) async {
98+ _provider.performAnswerCallAction = (answerCallAction ) async {
9499 // configure audio session
95- await startCallAction .fulfill();
100+ await answerCallAction .fulfill();
96101};
97102```
98103
99- #### Handling push notifications
104+ ### Handling push notifications
100105
101106Note: This SDK is not related to PushKit
102107
@@ -105,6 +110,7 @@ Push handling must be done through native iOS code due to [iOS 13 PushKit VoIP r
105110Flutter CallKit SDK has built-in reportNewIncomingCallWithUUID:callUpdate:providerConfiguration:pushProcessingCompletion:) method (iOS) to correctly work with it
106111
107112#### Swift
113+
108114``` swift
109115import Flutter
110116import flutter_callkit_voximplant
@@ -119,15 +125,15 @@ class AppDelegate: FlutterAppDelegate, PKPushRegistryDelegate {
119125 ) {
120126 processPush (with : payload.dictionaryPayload , and : nil )
121127 }
122-
128+
123129 func pushRegistry (_ registry : PKPushRegistry,
124130 didReceiveIncomingPushWith payload : PKPushPayload,
125131 for type : PKPushType,
126132 completion : @escaping () -> Void
127133 ) {
128134 processPush (with : payload.dictionaryPayload , and : completion)
129135 }
130-
136+
131137 // 2. process push
132138 private func processPush (with payload : Dictionary <AnyHashable , Any >,
133139 and completion : (() -> Void )?
@@ -156,6 +162,7 @@ class AppDelegate: FlutterAppDelegate, PKPushRegistryDelegate {
156162```
157163
158164#### Objective-C
165+
159166``` objective-c
160167#import < Flutter/Flutter.h>
161168#import < FlutterCallkitPlugin.h>
@@ -169,23 +176,23 @@ class AppDelegate: FlutterAppDelegate, PKPushRegistryDelegate {
169176@implementation AppDelegate
170177
171178// 1. override PKPushRegistryDelegate methods
172- - (void) pushRegistry:(PKPushRegistry * )registry
173- didReceiveIncomingPushWithPayload:(PKPushPayload * )payload
179+ - (void) pushRegistry:(PKPushRegistry * )registry
180+ didReceiveIncomingPushWithPayload:(PKPushPayload * )payload
174181 forType:(PKPushType)type {
175182 [ self processPushWithPayload: payload .dictionaryPayload
176183 andCompletionHandler: nil ] ;
177184}
178185
179- - (void) pushRegistry:(PKPushRegistry * )registry
186+ - (void) pushRegistry:(PKPushRegistry * )registry
180187didReceiveIncomingPushWithPayload:(PKPushPayload * )payload
181- forType:(PKPushType)type
188+ forType:(PKPushType)type
182189 withCompletionHandler:(void (^)(void))completion {
183190 [ self processPushWithPayload: payload .dictionaryPayload
184191 andCompletionHandler: completion ] ;
185192}
186193
187194// 2. process push
188- -(void)processPushWithPayload:(NSDictionary * )payload
195+ -(void)processPushWithPayload:(NSDictionary * )payload
189196 andCompletionHandler:(dispatch_block_t)completion {
190197 // 3. get uuid and other needed information from payload
191198 NSUUID * UUID = [[ NSUUID alloc] initWithUUIDString: payload [ @"UUID"] ] ;
@@ -194,8 +201,8 @@ didReceiveIncomingPushWithPayload:(PKPushPayload *)payload
194201 CXCallUpdate * callUpdate = [ CXCallUpdate new] ;
195202 callUpdate.localizedCallerName = localizedName;
196203 // 5. prepare provider configuration
197- CXProviderConfiguration * configuration =
198- [[ CXProviderConfiguration alloc]
204+ CXProviderConfiguration * configuration =
205+ [[ CXProviderConfiguration alloc]
199206 initWithLocalizedName:@"ExampleLocalizedName"] ;
200207 // 6. send it to plugin
201208 [ FlutterCallkitPlugin reportNewIncomingCallWithUUID: UUID
0 commit comments