Skip to content

Commit

Permalink
Merge pull request #246 from magbdev/dev
Browse files Browse the repository at this point in the history
Start incoming call action - new event
  • Loading branch information
hiennguyen92 authored Jan 5, 2024
2 parents 4dc4132 + 81610bc commit 2e3e9b8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class SwiftFlutterCallkitIncomingPlugin: NSObject, FlutterPlugin, CXProvi
private var data: Data?
private var isFromPushKit: Bool = false
private let devicePushTokenVoIP = "DevicePushTokenVoIP"

private var answerAction: CXAnswerCallAction?

private func sendEvent(_ event: String, _ body: [String : Any?]?) {
streamHandlers.reap().forEach { handler in
Expand Down Expand Up @@ -180,6 +182,10 @@ public class SwiftFlutterCallkitIncomingPlugin: NSObject, FlutterPlugin, CXProvi
case "getDevicePushTokenVoIP":
result(self.getDevicePushTokenVoIP())
break;
case "startCallIncoming":
self.answerAction?.fulfill()
result("OK")
break
default:
result(FlutterMethodNotImplemented)
}
Expand Down Expand Up @@ -485,8 +491,8 @@ public class SwiftFlutterCallkitIncomingPlugin: NSObject, FlutterPlugin, CXProvi
self?.sharedProvider?.reportOutgoingCall(with: call.uuid, connectedAt: call.connectedData)
}
self.answerCall = call
self.answerAction = action
sendEvent(SwiftFlutterCallkitIncomingPlugin.ACTION_CALL_ACCEPT, self.data?.toJSON())
action.fulfill()
}


Expand All @@ -508,7 +514,7 @@ public class SwiftFlutterCallkitIncomingPlugin: NSObject, FlutterPlugin, CXProvi
action.fulfill()
}
}else {
sendEvent(SwiftFlutterCallkitIncomingPlugin.ACTION_CALL_ENDED, self.data?.toJSON())
sendEvent(SwiftFlutterCallkitIncomingPlugin.ACTION_CALL_ENDED, call.data.toJSON())
action.fulfill()
}
}
Expand Down
8 changes: 8 additions & 0 deletions lib/flutter_callkit_incoming.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class FlutterCallkitIncoming {
return await _channel.invokeMethod("getDevicePushTokenVoIP");
}


/// Start incoming call
/// On iOS: start connection timer
/// On Android: not implemented
static Future startIncomingCall() async {
await _channel.invokeMethod("startCallIncoming");
}

/// Request permisstion show notification for Android(13)
/// Only Android: show request permission post notification for Android 13+
static Future requestNotificationPermission(dynamic data) async {
Expand Down

0 comments on commit 2e3e9b8

Please sign in to comment.