Skip to content

Commit

Permalink
Merge branch 'main' of github.com:SolankiYogesh/react-native-audio-focus
Browse files Browse the repository at this point in the history
  • Loading branch information
SolankiYogesh3500 committed Jun 10, 2023
2 parents 7ff4b64 + b9370e4 commit 3227774
Showing 1 changed file with 69 additions and 17 deletions.
86 changes: 69 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,83 @@
# react-native-audio-focus
## AudioFocus

The react-native-audio-focus package is a module for React Native that allows your app to handle audio focus events, such as incoming calls or other apps playing audio. It provides a way to respond to these events by firing events within your React Native application, enabling you to manage your app's audio playback and UI appropriately.
This package provides functionality to handle audio focus changes and incoming calls in a React Native application on Android.

## Installation
### Installation

```sh
npm install react-native-audio-focus
```
To install this package, follow these steps:

1. Install the package using npm or Yarn:

```bash
npm install react-native-audio-focus
```

or

```bash
yarn add react-native-audio-focus
```

2. Link the native module:

```bash
react-native link react-native-audio-focus
```

### Usage

To use the `AudioFocus` module in your React Native code, follow these steps:

1. Import the module:

## Usage
```javascript
import AudioFocus from 'react-native-audio-focus';
```

```js
import { multiply } from 'react-native-audio-focus';
2. Add listeners to handle audio focus changes and incoming calls:

// ...
```javascript
// Add listener for audio focus changes
AudioFocus.addListener('onAudioFocusChange', (focusChange) => {
// Handle audio focus change event
});

const result = await multiply(3, 7);
// Add listener for incoming calls
AudioFocus.addListener('onIncomingCall', () => {
// Handle incoming call event
});
```

3. Remove listeners when they are no longer needed:

```javascript
AudioFocus.removeListener();
```

### Permissions

Make sure to add the necessary permissions to your `AndroidManifest.xml` file to handle incoming calls:

```xml
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
```

## Contributing
### Troubleshooting

If you encounter any issues or errors while using this package, please refer to the [GitHub repository](https://github.com/SolankiYogesh/react-native-audio-focus) for further information and troubleshooting steps.

### License

This package is released under the [MIT License](https://opensource.org/licenses/MIT).

### Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
Contributions to this package are welcome! If you find any bugs or want to suggest new features, please open an issue or submit a pull request on the [GitHub repository]((https://github.com/SolankiYogesh/react-native-audio-focus/issues)).

## License
### Acknowledgments

MIT
This package is inspired by the [React Native Audio Focus]((https://github.com/SolankiYogesh/react-native-audio-focus)) package.

---
### Contact

Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
For any inquiries or questions, please contact [[email protected]](mailto:solankiyogesh3500@gmail.com).

0 comments on commit 3227774

Please sign in to comment.