cybex-dev / twilio_voice

Flutter Twilio Voice Plugin
https://twilio-voice-web.web.app/
MIT License
39 stars 84 forks source link

How to i can call from app to a number phone? #174

Closed tunbi closed 1 year ago

tunbi commented 1 year ago

I need to call from app to a number phone. I tried with call.place(to: '+8xxxx492', from: 'xxx-1', extraOptions: {"_TWI_SUBJECT": "Company Name"}) but it's seem that not work now.

cybex-dev commented 1 year ago

@tunbi Thanks for reporting the issue - do you have any additional information, handsets, devices, log outputs, ringing, etc status that could provide more insight?

tunbi commented 1 year ago

I am trying on the Simulator IOS: Iphone SE ver 16.4. I have register token id: final result = await TwilioVoice.instance.setTokens(accessToken: 'edadsfadsadxxxxxxx'); It's result: true After that i tried to using: Future<void> _onPerformCall(String clientIdentifier) async { if (!await (TwilioVoice.instance.hasMicAccess())) { print("request mic access"); TwilioVoice.instance.requestMicAccess(); return; } print("starting call to $clientIdentifier"); final result = TwilioVoice.instance.call.place(to: '+8xxxx492', from: 'xxx-1', extraOptions: {"_TWI_SUBJECT": "Company Name"}); print("result: $result"); } (I am calling from a userId that registered with Twillio to a number phone) I have a log that is 'true'. But when i check on the Twillio call log, it's seem that not available record on this. I am don't understand that what's wrong i get?

cybex-dev commented 1 year ago

I am trying on the Simulator IOS: Iphone SE ver 16.4. I have register token id: final result = await TwilioVoice.instance.setTokens(accessToken: 'edadsfadsadxxxxxxx'); It's result: true After that i tried to using: Future<void> _onPerformCall(String clientIdentifier) async { if (!await (TwilioVoice.instance.hasMicAccess())) { print("request mic access"); TwilioVoice.instance.requestMicAccess(); return; } print("starting call to $clientIdentifier"); final result = TwilioVoice.instance.call.place(to: '+8xxxx492', from: 'xxx-1', extraOptions: {"_TWI_SUBJECT": "Company Name"}); print("result: $result"); } (I am calling from a userId that registered with Twillio to a number phone) I have a log that is 'true'. But when i check on the Twillio call log, it's seem that not available record on this. I am don't understand that what's wrong i get?

Please check your Cal Records / TwiML (or backend) call logs including your /makeCall endpoint.

If the Twilio does not acknowledge the request nor triggering the `/makeCall, please check your auth token, check for any log error outputs. If the call is placed successfully via TwiML (Twilio Backend), please check for .voip push notifications received by the device.

cybex-dev commented 1 year ago

hi @tunbi, were you successful in resolving your issue(s)?

tunbi commented 1 year ago

Sorry for my late. It's seem that i can't get the right twillio token. But i resolved it. However i am missing with toggleMute and toggleSpeaker. It's seem that it's not working on it. This is code toggleMute:

void micOff() {
    isMuted = !isMuted;
    print("isMuted: $isMuted");
    TwilioVoice.instance.call.toggleMute(isMuted);
    notifyListeners();
  }

And toggleSpeaker:

`  void volumeUp() {
    isVolumnUp = !isVolumnUp;
    print("isVolumnUp: $isVolumnUp");
    TwilioVoice.instance.call.toggleSpeaker(isVolumnUp);
    notifyListeners();
  }

Finally, this is my code which listener 2 events above:

void listenForEvents() {
    TwilioVoice.instance.callEventsListener.listen((event) {
      print("voip-onCallStateChanged $event");
      switch (event) {
        case CallEvent.incoming:
          // applies to web only
          //   if (kIsWeb || Platform.isAndroid) {
          //     final activeCall = TwilioVoice.instance.call.activeCall;
          //     if (activeCall != null && activeCall.callDirection =        = CallDirection.incoming) {
          //       _showWebIncomingCallDialog();
          //     }
          //   }
          break;
        case CallEvent.ringing:
          final activeCall = TwilioVoice.instance.call.activeCall;
          if (activeCall != null) {
            final customData = activeCall.customParams;
            if (customData != null) {
              print("voip-customData $customData");
            }
          }
          break;
        case CallEvent.mute:
          print("CallEvent.mute");
          break;
        case CallEvent.unmute:
          TwilioVoice.instance.call.answer();
          break;
        case CallEvent.speakerOff:
          print("CallEvent.speakerOff");
          break;
        case CallEvent.speakerOn:
          print("CallEvent.speakerOn");
          break;
        case CallEvent.connected:
          break;
        case CallEvent.callEnded:
          print("CallEvent.callEnded");
          back();
          break;
        case CallEvent.answer:
          // if (kIsWeb || Platform.isAndroid) {
          //   final nav = Navigator.of(context);
          //   if (nav.canPop() && showingIncomingCallDialog) {
          //     nav.pop();
          //     showingIncomingCallDialog = false;
          //   }
          // }
          break;
        case CallEvent.declined:
          print("CallEvent.declined");
          break;
        default:
          break;
      }
    });

Should i action what can open call again after toggleMute or toggleSpeaker? It's not work with me.

cybex-dev commented 1 year ago

@tunbi there are a few things that appear wrong with the code snippets above (after formatting).

Custom volume control isn't integrated into twilio_voice yet though it is on the todo list.

To toggle mute, speaker and hold states, see this in the ReadMe.md via TwilioVoice.instance.call object.

tunbi commented 1 year ago

@cybex-dev I tried. But it's working with toggle speaker, but with Toggle mute, it's seem that can't talk to mic. It's always muted. Transmit audio to other number not working: both android and ios

Log: flutter: voip-onCallStateChanged CallEvent.log AVAudioSession setAggregatedIOPreference:error: Error Domain=NSOSStatusErrorDomain Code=560030580 "(null)" And one more, on Android, how I can make call with in app instead of calling system?

cybex-dev commented 1 year ago

180

tunbi commented 1 year ago

@cybex-dev And one more, on Android, how I can make call with in app instead of calling system?

cybex-dev commented 1 year ago

You'll have to revert back to 0.0.9

tunbi commented 1 year ago

Thank you for your support. Let me try.

tunbi commented 1 year ago

@cybex-dev So if i want to synchronize IOS as Android with Calling kit system, how to i can config?

tunbi commented 1 year ago

@cybex-dev i tried. With 0.0.9 audio also muted. It's not transmit audio. AVAudioSession setAggregatedIOPreference:error: Error Domain=NSOSStatusErrorDomain Code=560030580 "Operation not permitted while session has running audio I/Os" UserInfo={NSLocalizedDescription=Operation not permitted while session has running audio I/Os}

tunbi commented 1 year ago

@cybex-dev I tried run on the Ver 0.0.1. (Android 11) I see that log Event: Mute https://ibb.co/HCr4Vcd Screenshot-2023-10-20-at-11-52-02

cybex-dev commented 1 year ago

@tunbi are you looking for a solution as seen in 0.0.9 with the custom calling activity?

tunbi commented 1 year ago

@cybex-dev Yes, i tried. It's working well with the custom calling activity. But the audio still not transmit the audio on 0.0.9.

cybex-dev commented 1 year ago

@tunbi give this one a try twilio_voice_mimp though I suspect it might be a missing permission or configuration issue.

tunbi commented 1 year ago

@cybex-dev i see that they also based on your project. So it's not work still.

cybex-dev commented 1 year ago

@tunbi many apps including ours are using this (or twilio_voice_mimp) in production environment, I'd advise looking over your configuration and attempting to replicate using Google API 34 Android Emulator or iOS simulator with sandbox credentials.

cybex-dev commented 1 year ago

If you are able to replicate this in an emulator, this is considered a bug and will be addressed, alternatively if you're using a manufacturer who implements a unique ConnectionService implementation, this would require a twilio_voice update.

tunbi commented 1 year ago

@cybex-dev I am using with Trial account. I don't know that it's an issue?

cybex-dev commented 1 year ago

@tunbi I use trial accounts for testing with different platforms and environments - we haven't experienced any issues so far. Can you provide MCVE or set of steps describing / replicating your issue?

tunbi commented 1 year ago

@cybex-dev What is MCVE? We can call from Web to App successful. App to phone number via virtual number phone is just only fail with audio one-way. Phone receiver can not listen voice from Caller. I tried enable Voice Trace in the Voice setting. But i dont know that how to check it? haha.

cybex-dev commented 1 year ago

@tunbi this thread is getting unnecessarily long. If you encounter an issue, please provide a detailed set of steps to replicate the issue, as this would assist me in finding the issue.

Further, I would advise reviewing the getting started section for either Android / iOS platforms. twilio_voice_mimp is an updated version of twilio_voice 0.0.9 with several Android updates previously used in production with great success.