Skip to content

Android 11 background audio #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
geraintwhite opened this issue Sep 2, 2020 · 6 comments
Closed

Android 11 background audio #274

geraintwhite opened this issue Sep 2, 2020 · 6 comments
Labels
android help wanted Extra attention is needed question Further information is requested

Comments

@geraintwhite
Copy link
Contributor

With Android 11 upcoming there are some changes that will impact users of react-native-callkeep.

The permissions are once again being tightened, use of microphone in the background being relevant to VoIP apps.

When a call is started through CallKeep, the app won't be able to use the microphone until it is brought to the foreground.

It looks like there are some mitigations that can be put in place using foreground services.

@geraintwhite
Copy link
Contributor Author

I've made a super POC patch that fixes this on Android 11 by showing a persistent notification when a call is started. https://gist.github.com/grit96/597440c6a12243c6eecfc1b13c11833c

@zxcpoiu
Copy link
Member

zxcpoiu commented Sep 2, 2020

Thanks for the tips! 👍

Currently, there are some android devices ( on android 8+ or 9+ I guess ) stop the audio when app in the background for a while. The solution is similar, to start a foreground service when a call start.

So this may take into consideration (as a configurable opt in) that whether people already have their own foreground service flow or not.

FWIW, This is a library can handle foreground service in js side: https://github.com/voximplant/react-native-foreground-service
Not sure if it's enough to handle the voip case.

@danjenkins danjenkins added android help wanted Extra attention is needed question Further information is requested labels Sep 7, 2020
@sboily
Copy link
Member

sboily commented Sep 17, 2020

Hello, I'm using android 11 since the first beta and i don't have issue with audio in bacckground. I'm not sure to understand your issue...

@geraintwhite
Copy link
Contributor Author

@sboily Android 11 now requires the app to start a foreground service in order to use the camera or microphone in the background. If you don't have this issue it may be that you already start a foreground service in your app.

@danjenkins
Copy link
Collaborator

So this is what I was thinking the other day.... the connection service UI is classed as a fullscreen notification so gets classed as being foregrounded?

@geraintwhite
Copy link
Contributor Author

@danjenkins I'm not sure. In my case I'm using linphone for SIP calls and the only way I could get the audio to work when the call was started in the background was to have a foreground service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants