Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start incoming call action - new event #246

Merged
merged 3 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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