ion-phoner-js
v0.1.2
Published
Enhance Your Business Communication Productivity and Efficiency with Our Softphone and PBX Service
Maintainers
Readme
ION PHONER JS
Enhance Your Business Communication Productivity and Efficiency with Our Softphone and PBX Service
Experience the Ease of Unrestricted Communication
In today's digital age, effective and efficient communication is the cornerstone of running a successful business. Our softphone and PBX service is here to help you achieve that.
Benefits of Using Softphone and PBX Service
Boost productivity
Softphones empower you to make phone calls from anywhere, anytime, using any device connected to the internet. This allows you to stay connected with your team and your customers, even when you're on the go.
Enhance efficiency
PBX can automate many phone tasks, such as call forwarding, auto-attendants, and conferencing. This can save you time and money.
Reduce costs
Softphones and PBX can help you save money on phone bills by reducing long-distance call charges and phone hardware rental fees.
Increase scalability
Softphones and PBX can easily scale to meet the growing needs of your business.
Key Features of Our Softphone and PBX Service
HD voice quality
Enjoy crystal-clear and interference-free voice quality.
Comprehensive calling features
Make voice and video calls, send instant messages, and host conferences.
CRM integration
Integrate your softphone with your CRM to easily access customer information.
Monitoring and reporting
Monitor your call activity and get detailed reports on phone usage.
1. Installation
npm install ion-phoner-js
Example usage:
import IonPhoner from "ion-phoner-js";
const opt = {
credential: { host : 'https://example.com',
token : 'example-token',
userkey :'example-user'
},
config: {
dom: {
localVideo: document.querySelector('#localVideo') as HTMLElement,
remoteVideo: document.querySelector('#remoteVideo') as HTMLElement,
}
}
};
const phoner = new IonPhoner(opt);Make sure you have HTML elements with the IDs localVideo and remoteVideo in your index.html file or DOM.
<video id="localVideo" autoplay></video>
<video id="remoteVideo" autoplay></video>2. Connection
After initialization, call the connect() method to establish a connection to the server. The connection status will be updated via the isConnected variable.
let isConnected = false;
phoner.connect().then((e: any) => {
console.log('connect status', e);
isConnected = e?.status ?? false;
});3. Event Handling
You can listen to various events emitted by the phoner object to monitor the connection and registration status.
phoner.on('connection-status', (e: any) => {
console.log('connection-status', e);
});
phoner.on('registration-status', (e: any) => {
console.log('registration-status', e);
});4. Main Functions
The following functions are available in the phoner object for managing calls and status. Ensure isConnected is true before calling these functions.
4.1. register()
Registers a user to the phoner service.
function register() {
if (isConnected) phoner.register();
}4.2. unregister()
Unregisters a user from the phoner service.
function unregister() {
if (isConnected) phoner.unregister();
}4.3. hangup()
Ends an ongoing call.
function hangup() {
if (isConnected) phoner.hangup();
}4.4. hold()
Puts a call on hold.
function hold() {
if (isConnected) phoner.hold();
}4.5. unhold()
Cancels a call on hold.
function unhold() {
if (isConnected) phoner.unhold();
}4.6. answer()
Answers an incoming call.
function answer() {
if (isConnected) phoner.answer();
}4.7. mute()
Mutes the microphone.
function mute() {
if (isConnected) phoner.mute();
}4.8. unmute()
Unmutes the microphone.
function unmute() {
if (isConnected) phoner.unmute();
}4.9. dtmf(num: string)
Sends a DTMF (Dual-Tone Multi-Frequency) tone.
function dtmf(num: string) {
if (isConnected) phoner.dtmf(num);
}4.10. dial()
Initiates a call to the specified phone number.
function dial() {
const phone = (document.querySelector('#phone') as HTMLInputElement | null)?.value ?? '';
const call = phoner.call(phone);
console.log('call', call);
}Make sure you have an HTML element with the ID phone which is the input for the phone number.
<input type="text" id="phone" placeholder="Enter phone number">
<button onclick="dial()">Call</button>