Skip to content

Cordova Plugin For SIP Calls (IOS, Android) (Linphone Framework)

License

Notifications You must be signed in to change notification settings

estbeetoo/cordova-plugin-sip

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Cordova Plugin For SIP Calls (IOS, Android) (Linphone Framework)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 86.9%
  • C++ 10.4%
  • Java 0.9%
  • Roff 0.8%
  • Objective-C 0.6%
  • XSLT 0.3%
  • CMake 0.1%