From version < 48.1 >
edited by Simon Morlat
on 2020/06/25 12:46
To version < 49.1 >
edited by Danmei Chen
on 2020/06/25 16:23
< >
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.smorlat
1 +xwiki:XWiki.DanmeiChen
Content
... ... @@ -175,10 +175,24 @@
175 175  
176 176  * Add the **CallKit** framework into your application's dependencies in Xcode.
177 177  * Implement the **CXProviderDelegate** protocol within your **ApplicationDelegate**
178 -* Add the configuration **"use_callkit=1"** in the section **"app" **or call [[**linphone_core_enable_callkit()**>>https://www.linphone.org/snapshots/docs/liblinphone/swift/Classes/Core.html#/s:10linphonesw4CoreC14callkitEnabledSbvp]] before the linphone core starts.
179 -* Since iOS 13, Apple requests **CallKit **to be invoked to display the incoming call immediately when a **PushKit** notification is received. So sometimes you can answer the **CallKit** before a **LinphoneCall** is received. In the callback **CXAnswerCallAction**, if a **LinphoneCall** has not yet been received, you need to configure your **AVAudioSession** and accept the call when you receive it. Otherwise, accept the call directly.
178 +* Add the configuration **"use_callkit=1"** in the section **"app" **or call [[**linphone_core_enable_callkit()**>>https://www.linphone.org/snapshots/docs/liblinphone/swift/Classes/Core.html#/s:10linphonesw4CoreC14callkitEnabledSbvp]] before the linphone core starts.
179 +* **Your CallKit delegate** MUST inform the **LinphoneCore** when **AVAudioSession** is activated, as follows:
180 180  
181 181  {{code language="swift"}}
182 +func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
183 + lc.activateAudioSession(actived: true)
184 + }
185 +
186 +func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
187 + lc.activateAudioSession(actived: false)
188 + }
189 +{{/code}}
190 +
191 +==== Answer an incoming call ====
192 +
193 +Since iOS 13, Apple requests **CallKit **to be invoked to display the incoming call immediately when a **PushKit** notification is received. So sometimes you can answer the **CallKit** before a **LinphoneCall** is received. In the callback **CXAnswerCallAction**, if a **LinphoneCall** has not yet been received, you need to configure your **AVAudioSession** and accept the call when you receive it. Otherwise, accept the call directly.
194 +
195 +{{code language="swift"}}
182 182  func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
183 183   if (call == nil || call.state != Call.State.IncomingReceived) {
184 184   // configure audio session here. Use 48000 Hz as sampling rate.
... ... @@ -189,18 +189,97 @@
189 189  }
190 190  {{/code}}
191 191  
192 -* **Your CallKit delegate** MUST inform the **LinphoneCore** when **AVAudioSession** is activated, as follows:
206 +==== Terminate a call ====
193 193  
194 194  {{code language="swift"}}
195 -func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
196 - lc.activateAudioSession(actived: true)
197 - }
209 +func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
210 + // terminate call here
211 + action.fulfill()
212 +}
213 +{{/code}}
198 198  
199 -func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
200 - lc.activateAudioSession(actived: false)
201 - }
215 +==== Start an outgoing call ====
216 +
217 +When starting an outgoing call from the application view, it must following these steps:
218 +
219 + Add these codes to your class when starting an outgoing call
220 +
221 +{{code language="swift"}}
222 +let handle = CXHandle(type: .generic, value: displayName)
223 +let startCallAction = CXStartCallAction(call: uuid, handle: handle)
224 +let transaction = CXTransaction(action: startCallAction)
225 +let callController = CXCallController()
226 +callController.request(_ transaction: transaction, completion: @escaping (Error?) -> Void)
202 202  {{/code}}
203 203  
229 + Then this callback will be called.
230 +
231 +{{code language="swift"}}
232 +func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
233 + // start an outgoing call
234 + action.fulfill()
235 +}
236 +
237 +{{/code}}
238 +
239 +To ensure the audio session works properly for this outgoing call.
240 +
241 +{{code language="swift"}}
242 +// When outgoing call is created
243 +reportOutgoingCall(with UUID: UUID, startedConnectingAt dateStartedConnecting: Date?)
244 +// When outgoing call is answered
245 +reportOutgoingCall(with UUID: UUID, connectedAt dateConnected: Date?)
246 +
247 +
248 +{{/code}}
249 +
250 +==== Hold/resume a call ====
251 +
252 +{{code language="swift"}}
253 +func provider(_ provider: CXProvider, perform action: CXSetHeldCallAction) {
254 + // If this is a conference, leave/enter the conference.
255 + // Otherwide, pause/resume the call.
256 + action.fulfill()
257 +}
258 +
259 +{{/code}}
260 +
261 +==== Mute/un-mute a call ====
262 +
263 +{{code language="swift"}}
264 +func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
265 + // Mute/un-mute a call
266 + action.fulfill()
267 +}
268 +
269 +{{/code}}
270 +
271 +==== Play DTMF ====
272 +
273 +{{code language="swift"}}
274 +func provider(_ provider: CXProvider, perform action: CXPlayDTMFCallAction) {
275 + // Send DTMF
276 + action.fulfill()
277 +}
278 +{{/code}}
279 +
280 +==== Group calls ====
281 +
282 +{{code language="swift"}}
283 +func provider(_ provider: CXProvider, perform action: CXSetGroupCallAction) {
284 + // add all to conference
285 + action.fulfill()
286 +}
287 +{{/code}}
288 +
289 +==== Transfer a call ====
290 +
291 +Callkit does not support call transfer when Linphone does. If you wan to realise the call transfer with Callkit, you must follow these tips:
292 +
293 +* For callkit, an unique uuid represents a call.
294 +* For Linphone, the referred call will use a different callid than the original call.
295 +
296 +
204 204  == Technical solutions to advertise instant messages ==
205 205  
206 206  The table below summarizes the possible options. Remember that using PushKit is no longer possible since iOS 13 / Xcode 11.