Skip to content

Commit

Permalink
- fix callback reportCallAccepted;
Browse files Browse the repository at this point in the history
  • Loading branch information
TatankaConCube committed Sep 15, 2022
1 parent 0186111 commit 8cafd1f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2.2.0

- (iOS) Fix notifying plugin about call accepting;

Broken API:
- changed the signature of method `reportCallAccepted` by deleting the parameter `callType`;

## 2.1.0

- (Android) Add the possibility of setting a Notification icon;
Expand Down
19 changes: 15 additions & 4 deletions ios/Classes/CallKitController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ extension CallKitController {
private func requestTransaction(_ transaction: CXTransaction) {
callController.request(transaction) { error in
if let error = error {
print("CallKitController: Error requesting transaction: \(error)")
print("CallKitController: Error requesting transaction: \(error.localizedDescription)")
} else {
print("CallKitController: Requested transaction successfully")
}
Expand All @@ -229,17 +229,28 @@ extension CallKitController {
}

func startCall(handle: String, videoEnabled: Bool, uuid: String? = nil) {
print("CallKitController: user requested start call \(handle)")
print("CallKitController: user requested start call handle:\(handle), videoEnabled: \(videoEnabled) uuid: \(uuid ?? "")")
let handle = CXHandle(type: .generic, value: handle)
let callUUID = uuid == nil ? UUID() : UUID(uuidString: uuid!);
let callUUID = uuid == nil ? UUID() : UUID(uuidString: uuid!)
let startCallAction = CXStartCallAction(call: callUUID!, handle: handle)
startCallAction.isVideo = videoEnabled

let transaction = CXTransaction(action: startCallAction)

self.callStates[uuid!.lowercased()] = .accepted

requestTransaction(transaction)
requestTransaction(transaction);
}

func answerCall(uuid: String) {
print("CallKitController: user requested answer call, uuid: \(uuid)")
let callUUID = UUID(uuidString: uuid)
let answerCallAction = CXAnswerCallAction(call: callUUID!)
let transaction = CXTransaction(action: answerCallAction)

self.callStates[uuid.lowercased()] = .accepted

requestTransaction(transaction);
}
}

Expand Down
6 changes: 2 additions & 4 deletions ios/Classes/SwiftConnectycubeFlutterCallKitPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ public class SwiftConnectycubeFlutterCallKitPlugin: NSObject, FlutterPlugin {
}
else if(call.method == "reportCallAccepted"){
let callId = arguments["session_id"] as! String
let callType = arguments["call_type"] as! Int
let videoEnabled = callType == 1

SwiftConnectycubeFlutterCallKitPlugin.callController.startCall(handle: callId, videoEnabled: videoEnabled, uuid: callId)

SwiftConnectycubeFlutterCallKitPlugin.callController.answerCall(uuid: callId)
result(true)
}
else if (call.method == "reportCallFinished"){
Expand Down
9 changes: 3 additions & 6 deletions lib/src/connectycube_flutter_call_kit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,9 @@ class ConnectycubeFlutterCallKit {

/// Report that the current active call has been accepted by your application
///
static Future<void> reportCallAccepted({
required String? sessionId,
required int? callType,
}) async {
return _methodChannel.invokeMethod(
"reportCallAccepted", {'session_id': sessionId, 'call_type': callType});
static Future<void> reportCallAccepted({required String? sessionId}) async {
return _methodChannel
.invokeMethod("reportCallAccepted", {'session_id': sessionId});
}

/// Report that the current active call has been ended by your application
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: connectycube_flutter_call_kit
description: A Flutter plugin for displaying call screen when app in background or terminated.
version: 2.1.0
version: 2.2.0
homepage: https://github.com/ConnectyCube/connectycube-flutter-call-kit
issue_tracker: https://github.com/ConnectyCube/connectycube-flutter-call-kit/issues

Expand Down

0 comments on commit 8cafd1f

Please sign in to comment.