react-native-headphone-detection
Getting started
$ yarn add react-native-headphone-detection
Mostly automatic installation
-
For
react-native
0.60+:$ cd ios && pod install && cd .. -
For previous versions:
$ react-native link react-native-headphone-detection
Add permissions for android:
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/><uses-permission android:name="android.permission.BLUETOOTH" />
Usage
; // FunctionHeadphoneDetection;/* Output: { audioJack: boolean, bluetooth: boolean, }*/ // You can also use it as an event listenerHeadphoneDetection; // Don't forget to remove the listener!if HeadphoneDetectionremove // The remove is not necessary on Android HeadphoneDetection;