SIP.js icon indicating copy to clipboard operation
SIP.js copied to clipboard

Mobile Support

Open josephfrazier opened this issue 11 years ago • 28 comments

This is a general issue for discussing mobile support for SIP.js. See https://github.com/alongubkin/phonertc/issues/7

josephfrazier avatar Jun 05 '14 14:06 josephfrazier

Thanks for opening this Joseph. The use case is a cross platform app (Web, iOS, Android) that supports SIP calling. I've been working on a Phonegap plugin for PJSip, but its adding an extra layer of complexity that could be removed if we could get WebRTC working on iOS & Android.

Do you think something like PhoneRTC is worth pursuing for this use case?

lylepratt avatar Jun 05 '14 15:06 lylepratt

Take a look here at my response here: https://github.com/alongubkin/phonertc/issues/7

alongubkin avatar Jun 06 '14 12:06 alongubkin

I do not think that PhoneRTC in it's current state would work with SIP.js. What it does provide though is a good starting point at where mobile development is at.

For iOS I was able to recompile the WebRTC libraries (with SSL) and now I am working on creating an Obj-C layer to expose the needed WebRTC functions to SIP.js. My goal here would be to get SIP.js and iOS to be able to make WebRTC audio calls.

Once the audio functionality is solid, then I would begin working on adding video. My idea for video is to have a function that takes the id of an element on the page and pass that to Obj-C. Then have the native code find that element on the page and place a native video element over it. I think would probably create the best user experience. I am still open to other ideas on how to handle the video.

egreenmachine avatar Jun 06 '14 19:06 egreenmachine

@lylepratt, I just wanted to mention that although iOS support is in the works, you can have Android support simply by visiting the app website. Take a look at the SIP.js Demo Phone for a basic example. If you'd really like to have an Android app, you can use Crosswalk to bundle your web app together with a WebRTC-enabled WebView.

josephfrazier avatar Jun 09 '14 16:06 josephfrazier

@lylepratt, Here's a basic tutorial for using Crosswalk with SIP.js, if you're interested in that.

If you'd like to integrate Cordova plugins into your app, you can use Crosswalk Cordova to bring WebRTC functionality to Android apps generated by Cordova. After starting with Crosswalk Cordova's HelloWorld template, I was able to build the SIP.js Demo Phone app by replacing the assets/www directory with the demo phone assets and adding the following permissions to the AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

josephfrazier avatar Jun 11 '14 21:06 josephfrazier

Thanks for the info Joseph. Unfortunately we can only pursue something that works on iOS as well.

Based on these discussions, It looks like we're going to have to continue with a PJSip plugin in order to do that in a reasonable amount of time.

Maybe we can make the plugin conform to the SIP.js API. On Jun 11, 2014 2:26 PM, "Joseph Frazier" [email protected] wrote:

@lylepratt https://github.com/lylepratt, Here's a basic tutorial http://sipjs.com/guides/mobile/android-native/ for using Crosswalk with SIP.js, if you're interested in that.

If you'd like to integrate Cordova plugins into your app, you can use Crosswalk Cordova https://crosswalk-project.org/#documentation/cordova to bring WebRTC functionality to Android apps generated by Cordova. After starting with Crosswalk Cordova's HelloWorld template https://crosswalk-project.org/#documentation/cordova/develop_an_application, I was able to build the SIP.js Demo Phone http://sipjs.com/demo-phone/ app by replacing the assets/www directory with the demo phone assets https://github.com/onsip/sipjs-examples/tree/6d260bfd8e3e1655a881ad1cad446ed2672d6611/demo-phone and adding the following permissions to the AndroidManifest.xml:

— Reply to this email directly or view it on GitHub https://github.com/onsip/SIP.js/issues/31#issuecomment-45802303.

lylepratt avatar Jun 11 '14 21:06 lylepratt

I think I have a good sense of what needs to be done for SIP.js to use the PhoneRTC plugin for handling audio calls on iOS, so I'm planning to start working on a proof-of-concept tonight, as I'm personally interested in demonstrating this use case.

The general idea is to that iOS apps that use SIP.js would not use the default SIP.WebRTC.MediaHandler (that depends on JS having direct access to the PeerConnection, which we've seen isn't yet particularly feasible on iOS), but would provide a custom MediaHandler whose methods call into the PhoneRTC plugin.

We'd love for you to consider using SIP.js for your app, so I'll be sure to keep you posted on how my experiment goes.

josephfrazier avatar Jun 12 '14 21:06 josephfrazier

@joseph-onsip, per our discussion it was my understanding that the changes you were making are javascript application level changes. The custom media handler should be compatible with any platform implementing the phoneRTC api, and is not limited to iOS.

egreenmachine avatar Jun 12 '14 22:06 egreenmachine

Thats great news. I would love to experiment with your POC this weekend if you make any progress.

lylepratt avatar Jun 12 '14 23:06 lylepratt

Alright, I have made a bit of progress. Here's an app that can make calls to a WebRTC-enabled SIP endpoint running in a desktop browser (I tested with the SIP.js Demo Phone in Chrome).

Currently, it only works on Android, because that's what I'm developing against and I had to make a small change to the phonertc plugin. If the same change is made to the iOS plugin code, I'd expect this app to work on that platform as well, barring any platform-specific differences in WebRTC implementation.

josephfrazier avatar Jun 14 '14 03:06 josephfrazier

Wow. From looking at your code, getting it to work seemed fairly simple. You just overrode mediaHandlerFactory with PhoneRTCMediaHandler (along with your change to the PhoneRTC Plugin) and it "just worked"?

Edit: At first I thought that the PhoneRTCMediaHandler was included in PhoneRTC, but I now realize that you wrote that and this all makes much more sense.

lylepratt avatar Jun 14 '14 16:06 lylepratt

it "just worked"?

Well, I've only been able to get audio flowing between Android and Chrome (and, at the moment, only to Chrome, but I swear it was working when I last commented. I think it's that the app on my phone isn't properly playing back the stream, so I'm looking into modifying the plugin to get it working consistently), but yes, we've tried to make SIP.js very configurable in this regard. I was heavily involved in the refactor that made this sort of thing possible, which is one of the reasons I'm interested in getting together a working example of it.

josephfrazier avatar Jun 16 '14 01:06 josephfrazier

I think it's that the app on my phone isn't properly playing back the stream

Ugh, this turned out to be a WebRTC issue on my laptop. Rebooting fixed it.

Also, I was able to get two-way audio on a call from Chrome to Android (I had only gotten the other direction working previously). I just had to make sure Chrome was offering only audio and not also video.

I still haven't been able to call Firefox, so I made an issue for it.

josephfrazier avatar Jun 16 '14 02:06 josephfrazier

Android L has built in WebRTC support. We have created an iOS Cordova Plugin. Guides are available on sipjs.com.

egreenmachine avatar Nov 12 '14 16:11 egreenmachine

Any plans to port it to phonertc 2?

alongubkin avatar Nov 12 '14 17:11 alongubkin

@thomasquintana is working on porting it over to phonertc 2.0. It is almost finished.

lylepratt avatar Nov 12 '14 17:11 lylepratt

@alongubkin Tying up the loose ends now...look for a pull-request soon. Fork: https://github.com/BetterVoice/phonertc

@egreenmachine Here is an updated version of the media handler that works with the above fork (or will in a little bit). Also supports multiple sessions: https://github.com/BetterVoice/PhoneRTCMediaHandler

lylepratt avatar Nov 12 '14 19:11 lylepratt

Since information across other sources seems to be a bit scattered and this was recently modified, what is the recommended way for mobile integration right now @egreenmachine?

cybrox avatar Oct 13 '17 15:10 cybrox

I do not have much to report here, as you can probably tell from me removing the milestone. I can say that internally we are working on a mobile app using NativeScript and backed by SIP.js. I am hopeful that there might be some public facing results from that will allow SIP.js users to do the same in a simple manner. However, it is still too early to tell for sure. That being said, it is definitely possible to use the native WebRTC drivers, SIP.js, and NativeScript to make a mobile app. Once I have more to share I will update this issue.

egreenmachine avatar Oct 13 '17 16:10 egreenmachine

@cybrox SIP.Js version 0.7.8 can works on cordova with crosswalk on Android and iosrtc on iOS, the SIP.Js 0.9.2 however got some errors on RTC stuff.

@egreenmachine please work on the react native too, thank you :)

ostrichegret avatar Jan 22 '18 09:01 ostrichegret

@greenmachine curious on you guys effort with getting sipjs with nativescript. im running sipjs 0.7.8 with a cordova app but since sipjs isnt supporting cordova anymore on the lookout for potential replacement.

if you dont mind sharing the approach you guys use with nativescript? are you guys using the native webrtc ?

andrewvmail avatar Aug 18 '18 18:08 andrewvmail

@andrewvmail We ended up using native WebRTC and creating a custom SDH to interface with that. While I make it sound simple, it was far from that. At this point I do not think that we are going to make the implementation public. It is pretty difficult to get running and we expect the time we would have to commit to support it publicly too high. Additionally, it works for our app but it is a pretty specific implementation. We would have to do work to make it generic and we expect that people would run into issues trying to use it out the box. From the community activity we see it appears that most people want something that works out of the box with just some simple configuration parameters. This would not really be that.

For mobile, our target support is going to be the major mobile browsers. This would be Chrome on Android and Safari on iOS. If people would like to submit a PR back for SDH that they create for other environments, we would welcome it.

I hope that this clears up some of the cloud around mobile. Please reach out if you have any other questions or comments.

egreenmachine avatar Aug 20 '18 12:08 egreenmachine

I also ended up writing a custom SDH to carefully interface [email protected] with the provided cordova/iOS WebRTC implementation. It allowed my to solve an issue where cordova was complaining about the argument to RTCPeerConnection.setLocalDescription() & setRemoteDescription().

And have made it available as a publicly accessible npm library: https://github.com/WesUnwin/cordova-ios-session-description-handler

This may also be a useful example of how to write custom SDHs (in addition to the default SDH inside the SIP.js library which I also found to be a useful starting point). Hope this helps anyone!

WesUnwin avatar Feb 06 '19 05:02 WesUnwin

Any new updates on this?

I noticed:

“The bulk of SIP.js no longer cares about the media and what it’s doing, which opens up some exciting possibilities, like running it in a non-web browser, NativeScript on a phone, or Node.js on a desktop app,” notes James Criscuolo, Director of Software Engineering at OnSIP.

Ref: https://www.onsip.com/voip-news/onsip-news/sipjs-v0.8.0-supports-all-major-browsers-and-renegotiation

Is Nativescript supported?

sido420 avatar Oct 18 '20 20:10 sido420

We have built the OnSIP mobile app using Nativescript. That being said - getting the WebRTC libraries to run in Nativescript is not for beginners. Some users have reported success with react native and that may be path of least resistance.

egreenmachine avatar Oct 20 '20 12:10 egreenmachine

Hello, can you support Baidu browser(china)? Can register, can also send information, can not dial

jsb114110 avatar Jan 02 '21 04:01 jsb114110

Are there any up-to-date guides on running sip.js (0.20.X) in both Android and iOS? Does it work in a simple WebView? I'm assuming camera and media permissions are the issue.

InnovateAsterisk avatar Dec 09 '21 10:12 InnovateAsterisk

is there something i need to enable on ios 16, as the demo on the main page does not seem to work for me on safari

apaul0210 avatar May 11 '23 10:05 apaul0210