Skip to content

liaoyuan-io/react-native-call-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Native Call Detector

This package is designed to detect whether there is a phone call in background while the app is in foreground.

Install

yarn add react-native-call-detector

or

npm install react-native-call-detector --save

Link

react-native link react-native-call-detector

Example

import CallDetector from 'react-native-call-detector';

export class Example extends Component {
    componentWillMount() {
        this.callDetector = new CallDetector('call detector name', (event) => {
            const stateMap = {
                "Connected": () => {
                    console.log("Connected");
                },
                "Dialing": () => {
                    console.log("Dialing");
                },
                "Disconnected": () => {
                    console.log("Disconnected");
                },
                "Incoming": () => {
                    console.log("Incoming");
                }
            }
            stateMap[event]();
        });
    }

    componentWillUnmount() {
        this.callDetector && this.callDetector.dispose();
    }
}

About

React Native Call Detector

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published