From c319c8ed5203d62b25335187e27ba62addd2622b Mon Sep 17 00:00:00 2001 From: Hien Nguyen Date: Fri, 5 Jan 2024 18:11:30 +0700 Subject: [PATCH] Version 2.0.1 --- CHANGELOG.md | 10 +++ README.md | 69 +++++++++++++++++++ example/ios/Runner/AppDelegate.swift | 16 ++--- ios/Classes/Call.swift | 10 +-- .../SwiftFlutterCallkitIncomingPlugin.swift | 3 +- pubspec.yaml | 2 +- 6 files changed, 95 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d8fad4a..4648f013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 2.0.1 + +* Fixed some bugs. +* `Android` using Telecom Framework +* Add `silenceEvents` +* Add `normalHandle` props https://github.com/hiennguyen92/flutter_callkit_incoming/pull/403 +* Android add `textColor` props https://github.com/hiennguyen92/flutter_callkit_incoming/pull/398 +* Android invisible avatar for default https://github.com/hiennguyen92/flutter_callkit_incoming/pull/393 +* Add Method for call API when accept/decline/end/timeout + ## 2.0.0+2 * Fixed some bugs. diff --git a/README.md b/README.md index f06eb52f..a2679a3e 100644 --- a/README.md +++ b/README.md @@ -326,6 +326,75 @@ A Flutter plugin to show incoming call in your Flutter app(Custom for Android/Ca //Kotlin/Java Android FlutterCallkitIncomingPlugin.getInstance().sendEventCustom(body: Map) ``` + * 3.1 Call API when accept/decline/end/timeout + ```swift + //Appdelegate + ... + @UIApplicationMain + @objc class AppDelegate: FlutterAppDelegate, PKPushRegistryDelegate, CallkitIncomingAppDelegate { + ... + + // Func Call api for Accept + func onAccept(_ call: Call) { + let json = ["action": "ACCEPT", "data": call.data.toJSON()] as [String: Any] + print("LOG: onAccept") + self.performRequest(parameters: json) { result in + switch result { + case .success(let data): + print("Received data: \(data)") + + case .failure(let error): + print("Error: \(error.localizedDescription)") + } + } + } + + // Func Call API for Decline + func onDecline(_ call: Call) { + let json = ["action": "DECLINE", "data": call.data.toJSON()] as [String: Any] + print("LOG: onDecline") + self.performRequest(parameters: json) { result in + switch result { + case .success(let data): + print("Received data: \(data)") + + case .failure(let error): + print("Error: \(error.localizedDescription)") + } + } + } + + func onEnd(_ call: Call) { + let json = ["action": "END", "data": call.data.toJSON()] as [String: Any] + print("LOG: onEnd") + self.performRequest(parameters: json) { result in + switch result { + case .success(let data): + print("Received data: \(data)") + + case .failure(let error): + print("Error: \(error.localizedDescription)") + } + } + } + + func onTimeOut(_ call: Call) { + let json = ["action": "TIMEOUT", "data": call.data.toJSON()] as [String: Any] + print("LOG: onTimeOut") + self.performRequest(parameters: json) { result in + switch result { + case .success(let data): + print("Received data: \(data)") + + case .failure(let error): + print("Error: \(error.localizedDescription)") + } + } + } + ... + + ``` + Please check full: Example 4. Properties diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index aa05f104..1eb1a24e 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -83,8 +83,8 @@ import flutter_callkit_incoming // Func Call api for Accept func onAccept(_ call: Call) { - let json = ["action": "ACCEPT", "uuid": "XXX-XXX-XXX-XXX-ACCEPT"] - print("CCCC: onAccept") + let json = ["action": "ACCEPT", "data": call.data.toJSON()] as [String: Any] + print("LOG: onAccept") self.performRequest(parameters: json) { result in switch result { case .success(let data): @@ -98,8 +98,8 @@ import flutter_callkit_incoming // Func Call API for Decline func onDecline(_ call: Call) { - let json = ["action": "DECLINE", "uuid": "XXX-XXX-XXX-XXX-DECLINE"] - print("CCCC: onDecline") + let json = ["action": "DECLINE", "data": call.data.toJSON()] as [String: Any] + print("LOG: onDecline") self.performRequest(parameters: json) { result in switch result { case .success(let data): @@ -112,8 +112,8 @@ import flutter_callkit_incoming } func onEnd(_ call: Call) { - let json = ["action": "END", "uuid": "XXX-XXX-XXX-XXX-END"] - print("CCCC: onEnd") + let json = ["action": "END", "data": call.data.toJSON()] as [String: Any] + print("LOG: onEnd") self.performRequest(parameters: json) { result in switch result { case .success(let data): @@ -126,8 +126,8 @@ import flutter_callkit_incoming } func onTimeOut(_ call: Call) { - let json = ["action": "TIMEOUT", "uuid": "XXX-XXX-XXX-XXX-TIMEOUT"] - print("CCCC: onTimeOut") + let json = ["action": "TIMEOUT", "data": call.data.toJSON()] as [String: Any] + print("LOG: onTimeOut") self.performRequest(parameters: json) { result in switch result { case .success(let data): diff --git a/ios/Classes/Call.swift b/ios/Classes/Call.swift index d32933b1..4908efda 100644 --- a/ios/Classes/Call.swift +++ b/ios/Classes/Call.swift @@ -10,11 +10,11 @@ import AVFoundation public class Call: NSObject { - let uuid: UUID - let data: Data - let isOutGoing: Bool + public var uuid: UUID + public var data: Data + public var isOutGoing: Bool - var handle: String? + public var handle: String? var stateDidChange: (() -> Void)? var hasStartedConnectDidChange: (() -> Void)? @@ -240,7 +240,7 @@ public class Call: NSObject { } } - public func toJSON() -> [String: Any] { + open func toJSON() -> [String: Any] { let ios: [String : Any] = [ "iconName": iconName, "handleType": handleType, diff --git a/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift b/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift index c1e8d5f0..97b3860c 100644 --- a/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift +++ b/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift @@ -517,7 +517,8 @@ public class SwiftFlutterCallkitIncomingPlugin: NSObject, FlutterPlugin, CXProvi action.fail() return } - DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1000)) { + self.configurAudioSession() + DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1200)) { self.configurAudioSession() } call.hasConnectDidChange = { [weak self] in diff --git a/pubspec.yaml b/pubspec.yaml index d92cd618..06d0ac0f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_callkit_incoming description: Flutter Callkit Incoming to show callkit screen in your Flutter app. -version: 2.0.0+2 +version: 2.0.1 homepage: https://github.com/hiennguyen92/flutter_callkit_incoming repository: https://github.com/hiennguyen92/flutter_callkit_incoming issue_tracker: https://github.com/hiennguyen92/flutter_callkit_incoming/issues