backgroundPhoneCall function
void
backgroundPhoneCall()
Implementation
void backgroundPhoneCall() {
WidgetsFlutterBinding.ensureInitialized();
const _backgroundChannel = MethodChannel(backgroundMessagePhoneCallServiceChannel);
_backgroundChannel.setMethodCallHandler((call) async {
assert((() {
// ignore: avoid_print
print("callback $call!!!");
return true;
})());
switch (call.method) {
case onCallPhoneCallMethod:
// 忽略掉无用请求
if ((call.arguments["incomingNumber"] as String).isEmpty && call.arguments["state"] == 0) {
break;
}
final f = PluginUtilities.getCallbackFromHandle(CallbackHandle.fromRawHandle(call.arguments["callback"]));
/// [f] 非空
if (f != null) {
f(Map<String, dynamic>.from(call.arguments));
} else {
assert((() {
// ignore: avoid_print
print("callback is null !!!");
return true;
})());
}
break;
default:
assert((() {
// ignore: avoid_print
print([call.method, "not found", "arguments", call.arguments]);
return true;
})());
}
});
}