Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 933 Bytes

README.md

File metadata and controls

47 lines (34 loc) · 933 Bytes

react-native-silent

Library to detect if the device is in silent mode

WARNING!! This library only works for android, iOS still work in progress!

Installation

npm install react-native-silent

Usage

import Silent from "react-native-silent";

// ...Inside your functional component

  const getIsEnabled = () => {
    Silent.isEnabled().then((value) => {
      console.log('isEnabledValue changed', value);
      setIsEnabledValue(value);
    });
  };

  React.useEffect(() => {
    getIsEnabled();
    const listener = Silent.addListener((status) => {
      console.log('silentStatus changed', status);
      setSilentStatus(status);
    });
    () => {
      if (listener) {
        Silent.removeListener(listener);
      }
    };
  }, []);

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT