fedeamura / flutter_twilio

MIT License
1 stars 8 forks source link

Not getting data from android native side to flutter #9

Open HarishBirlangi242 opened 1 year ago

HarishBirlangi242 commented 1 year ago

I am using flutter_twilio package in my app for twilio calling. In calls screen I added one toggle button in native side, based on the button click I need to pass true/false to flutter side. After hitting the button I am calling the method channel but not getting the data to flutter side, and also I am not getting any errors. Below I added the code and flutter logs. Please help me to solve this.

I added new button to BackgroundCallJavaActivity.java file.

this.btnRecord = findViewById(R.id.btnRecord); this.btnRecord.setOnClickListener((v) -> this.toggleRecord(this.isRecord));

private void toggleRecord(boolean isRecordPass) { try { this.isRecord = !isRecordPass; applyColorToButton(this.btnRecord, isRecord); FlutterTwilioVoicePlugin.getInstance(this).onRecordChange(isRecord); Log.i(TAG, "toggle record executed"); } catch (Exception exception) { exception.printStackTrace(); } }

I added below code to FlutterTwilioVoicePlugin.java

public void onRecordChange(boolean isRecord) { if (isRecord) { Log.i(TAG, "recordStart :::"); responseChannel.invokeMethod("recordStart", true); } else { Log.i(TAG, "recordStop :::"); responseChannel.invokeMethod("recordStop", false); } }

I am listning the event in flutter_twilio_voice_android.dart

else if (event == "recordStart") { debugPrint("Record Start called 1"); return FlutterTwilioVoiceStatus.recordStart; } else if (event == "recordStop") { debugPrint("Record Stop called 1"); return FlutterTwilioVoiceStatus.recordStop; }

Flutter Logs: I/FlutterTwilioVoicePlugin( 8899): recordStart ::: I/BackgroundCallActivity( 8899): toggle record executed I/FlutterTwilioVoicePlugin( 8899): recordStop ::: I/BackgroundCallActivity( 8899): toggle record executed

HarishBirlangi242 commented 1 year ago

Hello @fedeamura Do I need add anything else other than a method channel to get data from native side(Call screen) to my app.