接听挂断电话

This commit is contained in:
GYJ
2024-11-28 13:49:26 +08:00
parent 1da1683adc
commit b6cd0d0f2b
13 changed files with 305 additions and 13 deletions

View File

@@ -13,4 +13,34 @@ class ChannelManager {
yjPrint('$kGetCallLog 发生异常:$e');
}
}
static Future<void> acceptCall() async {
MethodChannel channel = MethodChannel(getChannelName(kAcceptCall));
try {
final result = await channel.invokeMethod(kAcceptCall);
yjPrint(result);
} on PlatformException catch (e) {
yjPrint('$kAcceptCall 发生异常:$e');
}
}
static Future<void> rejectCall() async {
MethodChannel channel = MethodChannel(getChannelName(kRejectCall));
try {
final result = await channel.invokeMethod(kRejectCall);
yjPrint(result);
} on PlatformException catch (e) {
yjPrint('$kRejectCall 发生异常:$e');
}
}
static Future<void> endCall() async {
MethodChannel channel = MethodChannel(getChannelName(kEndCall));
try {
final result = await channel.invokeMethod(kEndCall);
yjPrint(result);
} on PlatformException catch (e) {
yjPrint('$kEndCall 发生异常:$e');
}
}
}

View File

@@ -5,6 +5,9 @@ const String kGetCallLog = 'getCallLog';
const String kCallLogCallback = 'callLogCallback';
const String kCallStatusChange = 'callStatusChange';
const String kAcceptCall = 'acceptCall';
const String kEndCall = 'endCall';
const String kRejectCall = 'rejectCall';
String getChannelName(name) {
return kChannelBaseName + name;