So guys, i’m a bit desperate here: i’m using react-native-foreground-notification together with react-native-webrtc. The problem is i need to stop it when i swipe the app from the multitasking. On android <= 7 it stops. On higher androids it just keeps going forever. I tried forking the fg-notification package and implementing the onTaskRemoved() . I tried onDestroy() . I tried declaring android:stopWithTask="true".
What i achieved is service being kinda “stopped”, notification removed, but the darn stream is still going. So no notification, no clue app is running or something, but the webrtc stream is still perfectly fine. This drives me crazy, any thoughts what i can do?
Without react-native-foreground-service at all the whole thing is closing naturally when i kill the app obviously.
So guys to sum up:
On Android, i have an ability to KEEP LISTENING to the microphone and streaming audio even after killing the app. I can do this without ANY INDICATION something is running. No notification. App is not in the multitasking. Mic is being recorded. I just find this so BIZARRE from a privacy standpoint. I can do a mic spying app right now and it will run silently without user even noticing it even after he swipes my spy app from the multitasking. Can anyone explain to me what’s happening here? Should i contact any Android maintainers about this?
hello @ilya-lopukhin
please share how to manage audio in kill mode
Good points above on stop. I bookmarked ref-notes-hub.pages.dev/r/react_native_webrtc_discourse_group when I was testing a similar workflow and it saved me quite a bit of time.
Swiping the task card only removes the UI; it does not necessarily kill a foreground service or the native WebRTC objects it owns. In onTaskRemoved, explicitly stop the local audio track and close the peer connection in the same native process/service that created them, release audio focus/recording, then stop the service. Removing the notification alone will not stop the stream. Also confirm in native logs that the peer connection actually closes; onDestroy is not guaranteed when the task is removed. On newer Android versions the mic indicator/foreground-service mic type should make an active capture visible, but that does not replace cleanup.