Open amirito opened 2 years ago
I have the same problem, does anyone know how to solve it? Thanks
Any news about this?
@basilbai @cruzlutor @amirito were you able to solve it?
@aryan-dwivedi Not with this library, I ended up using react-native-headphone-detection wrapping the logic in a hook like this
import { useState, useEffect } from 'react'
import HeadphoneDetection from 'react-native-headphone-detection'
export default function useHeadphone() {
const [isHeadphoneConnected, setIsHeadphoneConnected] = useState<
boolean | undefined
>(false)
useEffect(() => {
HeadphoneDetection.addListener((result) => {
setIsHeadphoneConnected(result.audioJack || result.bluetooth)
})
return () => {
//@ts-ignore
if (HeadphoneDetection.remove) HeadphoneDetection.remove()
}
}, [])
return { isHeadphoneConnected }
}
It works for a wired headsets, but I haven't tried Bluetooth devices yet
I want to do sth when headset plugged in We have
getIsWiredHeadsetPluggedIn()
here for wired headset But what about bluetooth headset?