StartCallAction transaction request failed: com.apple.CallKit.error.requesttransaction error 2
Issue Summary
When trying to call another Twilio registered Client from iOS device, this error pops up saying, StartCallAction transaction request failed: The operation couldn’t be completed. (com.apple.CallKit.error.requesttransaction error 2.). Calling used to work before (6-7 months back) so I don't know why is this failing now?
Here is a related SO answer.
Steps to Reproduce
- Call other Twilio registered Client from iOS device
- Notice the log when call fails
Future<Either<AppError, void>> place(
String from,
String to,
) async {
try {
await requestMicAccess();
bool? granted = await _instance.requestCallPhonePermission();
if (granted != true)
return Left(AppError(title: 'No call phone permission given.'));
bool? result = await _instance.call.place(
from: from,
to: to,
);
if (result != null && result) {
return Right(null);
}
return Left(AppError(title: 'Call placing failed.'));
} catch (e, st) {
print(e);
Sentry.captureException(e, stackTrace: st);
return Left(AppError(title: e.toString()));
}
}
flutter: ACTIVE CALL: VoipActiveCall(to: 4, from: 15, callDirection: CallDirection.outgoing, initiated: null, customParams: null)
[ERROR:flutter/shell/common/shell.cc(1055)] The 'twilio_voice/events' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel.
See https://docs.flutter.dev/platform-integration/platform-channels#channels-and-platform-threading for more information.
flutter: StartCallAction transaction request failed: The operation couldn’t be completed. (com.apple.CallKit.error.requesttransaction error 2.)
flutter: VOIP CALL EVENT: CallEvent.log
Have you checked on twilio logs?
- On ios try to look the certificate or voip you made it might be expired.
- On android needed to migrate v1 which using account service json which can be generate in gcp.
Hey @Erchil66 .
Have you checked on twilio logs?
Which Twilio logs are you referring to? The call is never started so it never reaches TwiML app because I didn't see anything in the console logs of the Twilio Function registered a a callback. I just get The operation couldn’t be completed. (com.apple.CallKit.error.requesttransaction error 2.) from Twilio SDK.
On ios try to look the certificate or voip you made it might be expired.
Receiving this from Twilio SDK: Successfully registered for VoIP push notifications.. So I'm guessing there might not be any issue with the VoIP certificate.
On android needed to migrate v1 which using account service json which can be generate in gcp.
On Android the call is started and System Phone Screen is shown. The call never reaches iOS. Couldn't test between two Android devices though so not sure if it works.
I updated VoIP certificate but the issue still persists.
@agent515 hi, also good day
I've been using the package almost 2 years now, I encountered this on my end for what i did was:
-
Follow the instructions to add asset for callKit_icon in xcode
-
On Xcode allow in Signing capabilities please check if have:
- Push Notifications
- Background Modes : (I have this but it's up to you to add the background fetch)
- Audio,Airplay and Picture in Picture
- Background fetch
- Remote Notification -Voice over ip
-
And for the pod i have like this
Add from here
target.build_configurations.each do |config| config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '14.1' # or whatever version you're using end
-
Then most of all the complicated for me the certificate to create .p12 files the certificate key and private key to be added in twilio and most of all check the token if have the token and the APP_SID in the token generated.
-
Also try to check the twiml;s might be something there also.
Those things worked for me. Actually
And i hope this helps.
Hey @Erchil66 , wish you a good day as well and thanks for all the help you've been doing!
So I just found the issue. I also had this package working for me for the past two years but just a few months back I added flutter_isolate to move some of the work off the main thread. And whenever you call flutterCompute with the callback, Twilio stops working properly even if it is not directly called or interacted with in that particular snippet. So I commented that part (invoking flutterCompute) out and calling started working again.
It seems that flutter_isolate package registers all the dependencies again for the new isolate. This issue might have been caused as a result of that. I am not 100% sure but I came to know about this because the app would throw a fatal error when trying to register twilio_voice again. I added workaround as below to circumvent the error but the SDK stopped working for me causing all these issues.
if !controller.hasPlugin("twilio_voice") {
let registrar = controller.registrar(forPlugin: "twilio_voice")
if let unwrappedRegistrar = registrar {
let eventChannel = FlutterEventChannel(name: "twilio_voice/events", binaryMessenger: unwrappedRegistrar.messenger())
eventChannel.setStreamHandler(self)
}
}