React Native Silent Switch
Detect the iOS silent switch using React Native
Install
rnpm
Using- Install:
rnpm install react-native-silent-switch
- Add
mute.caf
from the library to your project bundle- Project Navigator > [YOUR PROJECT NAME] > Build Phases > Copy Bundle Resources
- Verify that
$(SRCROOT)/../../node_modules/react-native/React
is in the library's header search paths for both Debug and Release schemes- Project Navigator > RCTSilentSwitch.xcodeproj > Build Settings > Header Search Paths > Debug AND Release
Manually
- Install:
npm install react-native-silent-switch --save
- Link library in Xcode: See React Native guide
- Add
mute.caf
from the library to your project bundle- Project Navigator > [YOUR PROJECT NAME] > Build Phases > Copy Bundle Resources
- Verify that
$(SRCROOT)/../../node_modules/react-native/React
is in the library's header search paths for both Debug and Release schemes- Project Navigator > RCTSilentSwitch.xcodeproj > Build Settings > Header Search Paths > Debug AND Release
Usage
{ // Listen for silent switch toggle events SilentSwitch} { SilentSwitch}
react-native-statusbar-alert
Usage with
{ SilentSwitch} { SilentSwitch} { return <View style=stylescontainer> <StatusBarAlert visible=thisstatealertslength > 0 ...thisstatealerts0 /> <Navigator initialRoute=initialRoute renderScene=thisrenderScene navigationBar= <NavigatorNavigationBar routeMapper=routeMapper style=top: -20 /> /> </View> }