1.6.1 • Published 11 months ago

react-native-telephony-manager v1.6.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

React Native Telephony Manager

Installation

Add the package to your react-native project in the following way

npm install react-native-telephony-manager

OR

yarn add react-native-telephony-manager

Link the current package to your react native project

react-native link react-native-telephony-manager

Usage

import Telephony from 'react-native-telephony-manager'

componentWillMount() {
  Telephony.addEventListener(Telephony.LISTEN_CALL_STATE | Telephony.LISTEN_DATA_ACTIVITY,
  (event) => {
    if (event.type === 'LISTEN_CALL_STATE') {
      console.log(event.data)
    } else {
      console.log(event.data)
    }
  })

  Telephony.isNetworkRoaming((roaming) => {
    if (roaming) {
      // ...
    }
  })

  Telephony.getNetworkClass((network) => {
    switch(network) {
      case "2G":
        // ...
      break;
      case "3G":
        // ...
      break;
      case "4G":
        // ...
      break;
      default:
        // ...
      break;
    }
  })

  Telephony.getCellInfo((cellInfos) => {
    celInfos.map((info) => {
      switch(info.connectionType) {
        case "CDMA":
          console.log(info.cellIdentity)
          console.log(info.cellSignalStrength)
        break;
        case "WCDMA":
          console.log(info.cellIdentity)
          console.log(info.cellSignalStrength)
        break;
        case "GSM":
          console.log(info.cellIdentity)
          console.log(info.cellSignalStrength)
        break;
        case "LTE":
          console.log(info.cellIdentity)
          console.log(info.cellSignalStrength)
        break;
        default:
          // ...
        break;
      }
    })
  })
}

componentWillUnmount() {
  Telephony.removeEventListener()
}

Events

Telephony.LISTEN_CALL_FORWARDING_INDICATOR
Telephony.LISTEN_CALL_STATE
Telephony.LISTEN_CELL_INFO
Telephony.LISTEN_CELL_LOCATION
Telephony.LISTEN_DATA_ACTIVITY
Telephony.LISTEN_DATA_CONNECTION_STATE
Telephony.LISTEN_MESSAGE_WAITING_INDICATOR
Telephony.LISTEN_SERVICE_STATE
Telephony.LISTEN_SIGNAL_STRENGTHS

LISTEN_CALL_STATE states

Telephony.CALL_STATE_IDLE
Telephony.CALL_STATE_RINGING
Telephony.CALL_STATE_OFFHOOK

LISTEN_DATA_ACTIVITY states

Telephony.DATA_ACTIVITY_NONE
Telephony.DATA_ACTIVITY_IN
Telephony.DATA_ACTIVITY_OUT
Telephony.DATA_ACTIVITY_INOUT
Telephony.DATA_ACTIVITY_DORMANT

LISTEN_DATA_CONNECTION_STATE states

Telephony.DATA_DISCONNECTED
Telephony.DATA_CONNECTING
Telephony.DATA_CONNECTED
Telephony.DATA_SUSPENDED

For any problems and doubt raise an issue.

1.6.1

11 months ago

1.6.0

11 months ago

1.5.9

11 months ago

1.5.8

11 months ago

1.5.7

11 months ago

1.5.6

11 months ago

1.5.5

11 months ago

1.5.4

11 months ago

1.5.3

11 months ago

1.5.2

11 months ago