Skip to content

OpenTelecom/react-sip-phone

Repository files navigation

react-sip-phone

SIP phone component for use in react projects

NPM JavaScript Style Guide

Install

npm install --save react-sip-phone

Usage

import React, { Component } from 'react'

import { ReactSipPhone } from 'react-sip-phone'
import 'react-sip-phone/dist/index.css'

class Example extends Component {
  render() {
    return <ReactSipPhone
        name={name}
        sipCredentials={{
          sipuri: sipuri,
          password: password
        }}
        sipConfig={{
          websocket: websocket,
          defaultCountryCode: '1'
        }}
        width={400}
      />
  }
}

To make calls from outside of the component, import the phone's store and access the SIP Account once it is registered

import { ReactSipPhone, phoneStore } from 'react-sip-phone'
class MyApp extends Component {

  makeCall(number) {
    const sipAccount = phoneStore.getState().sipAccounts.sipAccount
    if (sipAccount && number) {
      sipAccount.makeCall(number)
    }
  }

  render() {
    return <ReactSipPhone ... />
  }
}

License

MIT