ZEGOCLOUD / zego_uikit_prebuilt_call_flutter

MIT License
16 stars 13 forks source link

Android - Background State - Mic is not accessible #48

Closed codoffer closed 2 months ago

codoffer commented 3 months ago

Environment

Technology Version
Flutter version 3.22.2
Plugin version ^4.12.1
Android version 14
iOS version 17.4
macOS version
Xcode version 15.4
Google Chrome version 125.0.6422.142

Device information: Realme 11 Pro Plus - Android 14 (and other Android devices also)

Description

Expected behavior: A normal voice calls with all modes - foreground, background, and kill mode.

Current behavior:

During voice calls, if the user (callee or caller) closes the app or locks the phone. The app is not able to access the microphone and the audio gets muted. As a result, there is no audio from one side.

Steps to reproduce

Install with UI kit with basic flutter and check with the Android device (app in the background or locked status).

Additional efforts

After reading multiple articles, we tried to use foreground services for Android. We used one package (https://pub.dev/packages/flutter_foreground_task) to keep the call mic status active. But all was in vain.

We are looking for help with the above package or any alternative way to enable the mic during the background/kill state. What will be the service/function/method to be used with the above package to keep the mic accessible?

yoer commented 3 months ago

Please use foreground service to keep-alive. it cannot be embedded in UIKit, so you need to embed it yourself in your app.

codoffer commented 3 months ago

@yoer Thanks. Which service or method of zegocloud?

yoer commented 3 months ago

i mean, you can refer to plugins like flutter_background or flutter_foreground_task.

codoffer commented 3 months ago

I have tried these plugins. These plugins require a specific task to run in the foreground. I am unsure what the task or action will be to keep alive during the background or kill state. Will we have to stay alive with any specific zegocloud function?

codoffer commented 3 months ago

@yoer We are using only API for calling (https://www.zegocloud.com/docs/uikit/callkit-flutter/invitation-config/api-for-call-invitation). We have limited access to the calling screen with UI Kit.

Using the above plugins - We can put a specific code/action in the foreground mode. Here, I do not have any action or widget to put in the foreground. Please suggest more about this.

It's a major bug for the voice call feature.

atulproject99 commented 2 months ago

@yoer please give your suggestion on this in detail so we can implemented this

yoer commented 2 months ago

You need to implement app keeping alive by yourself, we do not provide a keeping alive solution in uikit.

this example should be keep alive during background, You can refer to it. The major code is [here]: (https://github.com/ZEGOCLOUD/zego_uikit_prebuilt_live_audio_room_example_flutter/tree/master/live_audio_room/android/app/src/main/kotlin/com/zegocloud/uikit/flutter/live_audio_room)

or you can refer this document.

Hope these can help you.

codoffer commented 2 months ago

@yoer Using this, we are getting another issue with the Android devices. The app keeps active with the locked screen and not getting any calls.

yoer commented 2 months ago

do you mean, the app is now kept alive in the background. but when the screen is locked, the call cannot be received?

yoer commented 2 months ago

How long do you lock the screen for? If it exceeds a certain time, an offline call will be triggered, which means you need to make some offline-related configurations to make normal.

You can refer to this document.

codoffer commented 2 months ago

Yes, I am aware of offline calls with background and killed state.

Issue The user locks the phone during the app in the foreground stage. The app keeps opening and not able to receive notifications or calls. It may be due to the wake lock, etc.

yoer commented 2 months ago

Can you give me a log and the specific time of occurrence (call time)?

Regarding how to get the logs, you can refer to the How ​​to get android device logs chapter of this document

codoffer commented 2 months ago

@yoer Please share your email address. I will share zip files.

yoer commented 2 months ago

iamyoer@gmail.com

yoer commented 2 months ago

document had updated

codoffer commented 2 months ago

@yoer We have tried with the updated document. It's crashing with Android 14.