diff --git a/src/components/SipProvider/index.js b/src/components/SipProvider/index.js index 1904591..80e1bdc 100644 --- a/src/components/SipProvider/index.js +++ b/src/components/SipProvider/index.js @@ -111,9 +111,14 @@ export default class SipProvider extends React.Component { } componentDidMount() { - // TODO check against having two instances of SipProvider in one app, which is not allowed - + if (window.document.getElementById('sip-provider-audio')) { + throw new Error(`Creating two SipProviders in one application is forbidden. If that's not the case ` + +`then check if you're using "sip-provider-audio" as id attribute for any existing ` + +`element`); + } + this.remoteAudio = window.document.createElement('audio'); + this.remoteAudio.id = 'sip-provider-audio'; window.document.body.appendChild(this.remoteAudio); this.reconfigureDebug(); @@ -137,6 +142,7 @@ export default class SipProvider extends React.Component { } componentWillUnmount() { + this.remoteAudio.parentNode.removeChild(this.remoteAudio); delete this.remoteAudio; if (this.ua) { this.ua.stop();