answer method

  1. @override
Future<bool?> answer()
override

Answers an inbound call. Returns true if successful, false otherwise. See twilio_js.Call.accept

Implementation

@override
Future<bool?> answer() async {
  if (_jsCall != null) {
    // Accept incoming call
    _jsCall!.accept();
    activeCall = activeCallFromNativeJsCall(_jsCall!);

    // attach event listeners
    _attachCallEventListeners(_jsCall!);

    // log event
    final params = getCallParams(_jsCall!);
    final from = params["From"] ?? "";
    final to = params["To"] ?? "";
    Logger.logLocalEventEntries(
      ["Answer", from, to, jsonEncode(params)],
      prefix: "",
    );

    // notify SW to cancel notification
    final callSid = await getSid();
    _cancelNotification(callSid!);

    return true;
  }
  return false;
}