Skip to content

Commit 4f3273c

Browse files
Merge pull request #99 from ConnectyCube/development
Release 2.2.4
2 parents 5a958e6 + 4507af4 commit 4f3273c

File tree

5 files changed

+46
-17
lines changed

5 files changed

+46
-17
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.2.4
2+
- (iOS) Improve the audio after accepting from the background or killed state;
3+
14
## 2.2.3
25
- (Android) Fix calling of the `onCallRejectedWhenTerminated` and the `onCallAcceptedWhenTerminated` callbacks in the release build;
36

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'com.connectycube.flutter.connectycube_flutter_call_kit'
2-
version '2.2.3'
2+
version '2.2.4'
33

44
buildscript {
55
ext.kotlin_version = '1.6.21'

ios/Classes/CallKitController.swift

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import Foundation
99
import AVFoundation
1010
import CallKit
1111

12-
13-
1412
enum CallEvent : String {
1513
case answerCall = "answerCall"
1614
case endCall = "endCall"
@@ -107,12 +105,13 @@ class CallKitController : NSObject {
107105
update.supportsHolding = false
108106
update.supportsDTMF = false
109107

108+
configureAudioSession(active: true)
110109
if (self.currentCallData["session_id"] == nil || self.currentCallData["session_id"] as! String != uuid) {
111110
print("[CallKitController][reportIncomingCall] report new call: \(uuid)")
112111
provider.reportNewIncomingCall(with: UUID(uuidString: uuid)!, update: update) { error in
113112
completion?(error)
114113
if(error == nil){
115-
self.configureAudioSession()
114+
self.configureAudioSession(active: true)
116115

117116
self.currentCallData["session_id"] = uuid
118117
self.currentCallData["call_type"] = callType
@@ -173,15 +172,30 @@ class CallKitController : NSObject {
173172
self.callsData.removeAll()
174173
}
175174

176-
func configureAudioSession(){
175+
func sendAudioInterruptionNotification(){
176+
var userInfo : [AnyHashable : Any] = [:]
177+
let intrepEndeRaw = AVAudioSession.InterruptionType.ended.rawValue
178+
userInfo[AVAudioSessionInterruptionTypeKey] = intrepEndeRaw
179+
userInfo[AVAudioSessionInterruptionOptionKey] = AVAudioSession.InterruptionOptions.shouldResume.rawValue
180+
NotificationCenter.default.post(name: AVAudioSession.interruptionNotification, object: self, userInfo: userInfo)
181+
}
182+
183+
func configureAudioSession(active: Bool){
184+
print("CallKitController: [configureAudioSession]")
177185
let audioSession = AVAudioSession.sharedInstance()
178186

179187
do {
180-
try audioSession.setCategory(AVAudioSession.Category.playback, options: AVAudioSession.CategoryOptions.allowBluetooth)
181-
try audioSession.setMode(AVAudioSession.Mode.voiceChat)
188+
try audioSession.setCategory(
189+
AVAudioSession.Category.playAndRecord,
190+
options: [
191+
.allowBluetooth,
192+
.allowBluetoothA2DP,
193+
.duckOthers,
194+
])
195+
try audioSession.setMode(AVAudioSession.Mode.videoChat)
182196
try audioSession.setPreferredSampleRate(44100.0)
183197
try audioSession.setPreferredIOBufferDuration(0.005)
184-
try audioSession.setActive(true)
198+
try audioSession.setActive(active)
185199
} catch {
186200
print(error)
187201
}
@@ -262,14 +276,28 @@ extension CallKitController: CXProviderDelegate {
262276

263277
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
264278
print("CallKitController: Answer Call \(action.callUUID.uuidString)")
265-
actionListener?(.answerCall, action.callUUID, currentCallData)
266-
self.callStates[action.callUUID.uuidString.lowercased()] = .accepted
279+
280+
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1200)) {
281+
self.configureAudioSession(active: true)
282+
}
283+
284+
callStates[action.callUUID.uuidString.lowercased()] = .accepted
285+
actionListener?(.answerCall, action.callUUID, self.currentCallData)
286+
267287
action.fulfill()
268288
}
269289

270290
func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
271291
print("CallKitController: Audio session activated")
272-
self.configureAudioSession()
292+
293+
if(currentCallData["session_id"] != nil
294+
&& callStates[currentCallData["session_id"] as! String] == .accepted){
295+
sendAudioInterruptionNotification()
296+
return
297+
}
298+
299+
sendAudioInterruptionNotification()
300+
configureAudioSession(active: true)
273301
}
274302

275303
func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
@@ -279,7 +307,7 @@ extension CallKitController: CXProviderDelegate {
279307
func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
280308
print("CallKitController: End Call")
281309
actionListener?(.endCall, action.callUUID, currentCallData)
282-
self.callStates[action.callUUID.uuidString.lowercased()] = .rejected
310+
callStates[action.callUUID.uuidString.lowercased()] = .rejected
283311
action.fulfill()
284312
}
285313

@@ -303,9 +331,7 @@ extension CallKitController: CXProviderDelegate {
303331
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
304332
print("CallKitController: Start Call")
305333
actionListener?(.startCall, action.callUUID, currentCallData)
306-
self.callStates[action.callUUID.uuidString.lowercased()] = .accepted
334+
callStates[action.callUUID.uuidString.lowercased()] = .accepted
307335
action.fulfill()
308336
}
309337
}
310-
311-

ios/connectycube_flutter_call_kit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
Pod::Spec.new do |s|
66
s.name = 'connectycube_flutter_call_kit'
7-
s.version = '2.2.3'
7+
s.version = '2.2.4'
88
s.summary = 'Connectycube Call Kit plugin for flutter.'
99
s.description = <<-DESC
1010
Connectycube Call Kit plugin for flutter.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: connectycube_flutter_call_kit
22
description: A Flutter plugin for displaying call screen when app in background or terminated.
3-
version: 2.2.3
3+
version: 2.2.4
44
homepage: https://github.com/ConnectyCube/connectycube-flutter-call-kit
55
issue_tracker: https://github.com/ConnectyCube/connectycube-flutter-call-kit/issues
66

0 commit comments

Comments
 (0)