Git Product home page Git Product logo

cordova-plugin-sip's Introduction

cordova-plugin-sip

SIP plugin for Cordova & Phonegap Apps (IOS and Android)

IOS

Build Settings -> Header Search Paths

    "$(SRCROOT)/YOURPROJECTNAME/Plugins/cordova-plugin-sip/include"
    "$(SRCROOT)/YOURPROJECTNAME/Plugins/cordova-plugin-sip/include/belle-sip"
    "$(SRCROOT)/YOURPROJECTNAME/Plugins/cordova-plugin-sip/include/ortp"
    "$(SRCROOT)/YOURPROJECTNAME/Plugins/cordova-plugin-sip/include/linphone"
    "$(SRCROOT)/YOURPROJECTNAME/Plugins/cordova-plugin-sip/include/mediastreamer2"

You must import these files in the Bridging Header File

    #include "Plugins/cordova-plugin-sip/include/linphone/lpconfig.h"
    #include "Plugins/cordova-plugin-sip/include/linphone/linphonecore.h"
    #include "Plugins/cordova-plugin-sip/include/linphone/linphonecore_utils.h"

IOS Permissions

You must include following permissions

        <key>NSCameraUsageDescription</key>
        <string>Description Why you use this permission</string>
        <key>NSMicrophoneUsageDescription</key>
        <string>Description Why you use this permission</string>

Android

Deploy and Run!

Usage

var sipManager = {
    register: function () {
        cordova.plugins.sip.login('102', '102', '192.168.1.22:5060', 'udp', sipManager.events, sipManager.events);
    },
    call: function () {
        cordova.plugins.sip.call('sip:[email protected]:5060', '203', function (e) {
        }, function (e) {
        })
    },

    hangup: function () {
        cordova.plugins.sip.hangup(function (e) {}, function (e) {})
    },
               
    accept: function () {
        cordova.plugins.sip.accept(function (e) {}, function (e) {})
    },
   
    dtmf: function (dtmf) {
        cordova.plugins.sip.sendDtmf(dtmf, function (e) {}, function (e) {})
    },

    events: function (event) {
        console.log(event);

        var e = JSON.parse(event).status;

        if (e == 'RegistrationOk') {
            alert("RegistrationOk");
        }
        if (e == 'RegistrationError') {
            alert("Registration Failed!");
        }
        if (e == 'CallIncomingReceived') {
            var r = confirm("Incoming Call");
            if (r == true) {
                console.log("call from user " + JSON.parse(event).username);
                sipManager.accept();
            } else {
                sipManager.hangup();
            }
        }
        if (e == 'CallError') {
            alert("Call Error!");
        }
        if (e == 'CallEnd') {
            alert("Call End!");
        }
    }
}

Event message

Event message it is json.

Fromat json response {"status": TYPE }

Registration type for json status

RegistrationNone -> Initial state for registrations 
RegistrationProgress -> Registration is in progress 
RegistrationOk -> Registration is successful 
RegistrationCleared -> Unregistration succeeded 
RegistrationFailed</h4>  

Call type for json status

CallIdle -> Initial call state 
CallIncomingReceived -> This is a new incoming call  ( For this type, added new field exsample {"status":"CallIncomingReceived", "username":"username"} )
CallOutgoingInit -> An outgoing call is started 
CallOutgoingProgress -> An outgoing call is in progress 
CallOutgoingRinging -> An outgoing call is ringing at remote end 
CallOutgoingEarlyMedia -> An outgoing call is proposed early media 
CallConnected -> Connected, the call is answered 
CallStreamsRunning -> The media streams are established and running
CallPausing -> The call is pausing at the initiative of local end 
CallPaused -> The call is paused, remote end has accepted the pause 
CallResuming -> The call is being resumed by local end
CallRefered -> The call is being transfered to another party, resulting in a new outgoing call to follow immediately
CallError -> The call encountered an error
CallEnd -> The call ended normally
CallPausedByRemote -> The call is paused by remote end
CallUpdatedByRemote -> The call's parameters change is requested by remote end, used for example when video is added by remote 
CallIncomingEarlyMedia -> We are proposing early media to an incoming call 
CallUpdating -> A call update has been initiated by us 
CallReleased -> The call object is no more retained by the core 
CallEarlyUpdatedByRemote -> The call is updated by remote while not yet answered (early dialog SIP UPDATE received).
CallEarlyUpdating -> We are updating the call while not yet answered (early dialog SIP UPDATE sent)

Other type for json status

SendDtmf -> Send DTMF message

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.