Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebRTC #11

Open
Ionitron opened this issue Jun 17, 2020 · 58 comments
Open

WebRTC #11

Ionitron opened this issue Jun 17, 2020 · 58 comments
Labels
incompatible cordova plugin exists An incompatible Cordova plugin exists already plugin proposal

Comments

@Ionitron
Copy link
Member

Plugin Request

Name: WebRTC
Package: @capacitor-community/webrtc

Platform(s)

iOS

Existing Solutions

Description

Ability to access MediaDevices.getUserMedia() natively for iOS to work with WebRTC.

@Ionitron
Copy link
Member Author

Original request: ionic-team/capacitor#2944

@danielehrhardt
Copy link

This would be nice!

@phairow
Copy link

phairow commented Jul 2, 2020

👍

@imhoffd
Copy link
Contributor

imhoffd commented Jul 2, 2020

@phairow Upvote the original post so people can sort by it.

@phairow
Copy link

phairow commented Jul 2, 2020

Sure thing

@bizready
Copy link

bizready commented Jul 5, 2020

it would be awesome to have this pugin

@RobbieTheWagner
Copy link

As far as I can tell, without this there is no way to use getUserMedia with capacitor on iOS, correct? This would be great to have!

@bizready
Copy link

bizready commented Jul 6, 2020

It is not just getUserMedia(). I am also getting an error with navigator.mediaDevices.addEventListener

@RobbieTheWagner
Copy link

Yeah navigator.mediaDevices does not exist, so all of its methods are not usable currently.

@bizready
Copy link

bizready commented Jul 6, 2020

Interesting. The same code works fine in a browser environment or maybe it is not called in a browser environment. When deploying the code mobile, I get the error TypeError: undefined is not an object (evaluating 'navigator.mediaDevices.addEventListener'). Could you please point me to the link regarding navigator.mediaDevices that it does not exist? The code is part of the AWS Chime library so that I can report?

@RobbieTheWagner
Copy link

@bizready it's a limitation of iOS. This issue here is the only possible fix. It has to be supported in Capacitor since iOS does not have it by default. There is a Cordova plugin, but it doesn't work with Capacitor. https://github.com/cordova-rtc/cordova-plugin-iosrtc

@bizready
Copy link

bizready commented Jul 7, 2020

Thanks @rwwagner90. I am experimenting with using https://github.com/cordova-rtc/cordova-plugin-iosrtc and it is very promising!

@RobbieTheWagner
Copy link

@bizready as I mentioned, that Cordova plugin does not work with Capacitor.

@bizready
Copy link

bizready commented Jul 7, 2020

@rwwagner90 - I am using Quasar framework (one code base for web, mobile, and desktop). I can easily build code for Cordova or Capacitor. That way, I am in a good situation!

@RobbieTheWagner
Copy link

@bizready sure, but then you are not using capacitor and this feature request is for capacitor. Those of us using capacitor are still stuck.

@bizready
Copy link

bizready commented Jul 7, 2020

For the time being (POC), I am ok in using Cordova. I want to use Capacitor. I do know that Capacitor can use Cordova plugins, that does not mean that isoRTC can be readily used in Capacitor. I am thinking that with some custom code, may be isoRTC can be used in Capacitor until we have Capacitor specific plugin?

@pszalanski
Copy link

There is actually a bug filed in the webkit bugtracker: https://bugs.webkit.org/show_bug.cgi?id=208667

If you want to push Apple to fix that issue you can follow the instructions in the comments to show Apple that you are affected by this missing feature.

@RobbieTheWagner
Copy link

I am thinking that with some custom code, may be isoRTC can be used in Capacitor until we have Capacitor specific plugin?

I saw a comment somewhere from the Capacitor team saying it won't work. I forget where I saw it.

@phairow
Copy link

phairow commented Jul 9, 2020

I have it(iosRTC) working with capacitor. Only odd issue is having to manage the binary within node_modules folder so it gets picked up on sync.

@RobbieTheWagner
Copy link

@phairow how did you get it working?

@phairow
Copy link

phairow commented Jul 10, 2020

https://github.com/phairow/pubnubchatrcionic You can see my repo. You will see most of the settings I had to do documented in custom/publish.md. The final step was to disable bitcode for the app.

@imhoffd imhoffd added the incompatible cordova plugin exists An incompatible Cordova plugin exists already label Jul 13, 2020
@gabsgasps
Copy link

This plugin would be nice!

@CloudROMB
Copy link

In the era of Zoom and telemedicine the WebRTC plugin is really necessary.

@imhoffd
Copy link
Contributor

imhoffd commented Nov 23, 2020

navigator.mediaDevices.getUserMedia is implemented in iOS 14.3 beta according to this: https://webkit.org/blog/11353/mediarecorder-api/

@rudyhadoux
Copy link

rudyhadoux commented Dec 17, 2020

Hi,
Is there a way to get a video stream (MediaStream) from Capacitor Camera.getPhoto( ) ?

@7freaks-otte
Copy link

@dwieeb From my current tests it seems that navigator.mediaDevices.getUserMedia is indeed implemented in iOS 14.3. and my app correctly asks for the Camera permissions. But getUserMedia still fails with NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

According to https://bugs.webkit.org/show_bug.cgi?id=208667 the reason is that capacitor uses the custom URL scheme capacitor://, I tried to change it do https://localhost:3000 via capacitor.config.json but while I was able to change the host to localhost:3000 the scheme capacitor:// does not seem be changeable on iOS.

@imhoffd
Copy link
Contributor

imhoffd commented Jan 8, 2021

@7freaks-otte Looks like that's being addressed: WebKit/WebKit@ff60f0a

@danielehrhardt
Copy link

Hello,

I'm using ionic 5 with capacitor and angular9. and i have the same problem as @7freaks-otte.
When i build the app on ios, I reveice an "notallowederror" at the line navigation.getUsermedia.
If i understand well, it doesn't work natively and any plugin works with capacitor.

So today there is no way today to get the stream with capacitor ?

https://github.com/cordova-rtc/cordova-plugin-iosrtc

@iometrine
Copy link

Doest https://github.com/cordova-rtc/cordova-plugin-iosrtc work with capacitor ?

@danielehrhardt
Copy link

danielehrhardt commented Feb 15, 2021

@iometrine
Copy link

Thank you for your answer @danielehrhardt butI didn't succes to install it on my project

Can i use this plugin ?
https://www.npmjs.com/package/cordova-plugin-iosrtc-capacitor

Or how can i install this plugin on my ionic capacitor project ?
Do i need to build or something else ?

@danielehrhardt
Copy link

Thank you for your answer @danielehrhardt butI didn't succes to install it on my project

Can i use this plugin ?
https://www.npmjs.com/package/cordova-plugin-iosrtc-capacitor

Or how can i install this plugin on my ionic capacitor project ?
Do i need to build or something else ?

It is on your side. I have it running since several months now in my ionic capacitor app.

@iometrine
Copy link

I installed it like that
npm install cordova-plugin-iosrtc-capacitor

and i put this code in my podfile:

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# Disable bitcode in order to support cordova-plugin-iosrtc
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end

Did I miss something ?

@7freaks-otte
Copy link

@iometrine I haven't tried "cordova-plugin-iosrtc-capacitor" yet, so I'm just guessing until I have time to do so: As far as I understand, the plugin exposes the iOS workaround as cordova.plugins.iosrtc, so don't forget to call cordova.plugins.iosrtc.registerGlobals(); to be able to use the standard functions like navigator.mediaDevices.getUserMedia()

@iometrine
Copy link

My problem is when i try to install the plugin iosrtc
npm i cordova-plugin-iosrtc

i can't pass the first command:
node ios_arch.js --extract
I have an error

for information i try to follow this:
https://github.com/cordova-rtc/cordova-plugin-iosrtc/blob/master/docs/Building.md#capacitor

@7freaks-otte
Copy link

I would skip this step for now as you only need to do it before Apple App Store submission. Try to get it running on a real device first.

@danielehrhardt
Copy link

I would skip this step for now as you only need to do it before Apple App Store submission. Try to get it running on a real device first.

I never did run this command.

@iometrine
Copy link

when i install cordova-plugin-iosrtc in my capacitor project with npm install cordova-plugin-iosrtc
i've got many errors "undefined symbol" when i build on ios like
objc_class$_RTCMediaConstraints

Can you help me ?

@iometrine
Copy link

I 've got this error:
Could not find or use auto-linked framework 'WebRTC'

@iometrine
Copy link

any idea ?

@iometrine
Copy link

hello,

@danielehrhardt @7freaks-otte apparently cordova-plugin-iosrtc doesn't work on capacitor.

ionic-team/capacitor#3066

@danielehrhardt
Copy link

hello,

@danielehrhardt @7freaks-otte apparently cordova-plugin-iosrtc doesn't work on capacitor.

ionic-team/capacitor#3066

It does work 🙈

@iometrine
Copy link

@danielehrhardt when i install it and when i build on xcode i've got many errors "undefined symbol" like objc_class$_RTCMediaConstraints
So what did you do ?

@iometrine
Copy link

@danielehrhardt can you say something constructive except that it works?

@danielehrhardt
Copy link

danielehrhardt commented Feb 26, 2021

https://github.com/danielehrhardt/ionic-capacitor-iosrtc-test
use a real device no emulator to test

@iometrine
Copy link

thank you @danielehrhardt it works now.
I compared your project with mine, and finally i found what was the difference.
I just needed your podfile :)
It's weird because when i tried to build with the part of code indicated in the doc, it doesn't work:
https://github.com/cordova-rtc/cordova-plugin-iosrtc/blob/master/docs/Building.md#cocoapods

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      # Disable bitcode in order to support cordova-plugin-iosrtc
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

But with the code in your podfile it works like a charm:

def disable_bitcode_for_target(target)
  target.build_configurations.each do |config|
    config.build_settings['ENABLE_BITCODE'] = 'NO'

    remove_cflags_matching(config.build_settings, ['-fembed-bitcode', '-fembed-bitcode-marker'])
  end
end

def remove_cflags_matching(build_settings, cflags)
  existing_cflags = build_settings['OTHER_CFLAGS']

  removed_cflags = []
  if !existing_cflags.nil?
    cflags.each do |cflag|
      existing_cflags.delete_if { |existing_cflag| existing_cflag == cflag && removed_cflags << cflag }
    end
  end

  if removed_cflags.length > 0
    build_settings['OTHER_CFLAGS'] = existing_cflags
  end
end

post_install do |installer|
  project_name = Dir.glob("*.xcodeproj").first
  project = Xcodeproj::Project.open(project_name)
  project.targets.each do |target|
    disable_bitcode_for_target(target)
  end
  project.save

  installer.pods_project.targets.each do |target|
    disable_bitcode_for_target(target)
  end

  installer.pods_project.save
end

Now I can acces to the stream of the camera with navigator.getUserMedia
I've added this line before the export of my class
declare var cordova: any;
and this line on the constructor
cordova.plugins.iosrtc.registerGlobals();

Thank you again for your help :)

@karen1au
Copy link

@imhoffd Hi! I'm still seeing NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission. in my app, I'm on capacitor 2.4.6, do I need to manually update anything? Thanks!

@iometrine
Copy link

are you using cordova or capacitor?
Did you success to install the plugin cordova-plugin-iosrtc ?
Did you well register cordova.plugins.iosrtc.registerGlobals(); to override the native js function getUserMedia ?

Do you use navigator.getUserMedia or navigator.mediaDevices.getUserMedia?

We need futher information if you want we help you.

@karen1au
Copy link

@iometrine Thanks for getting back! I'm using Capacitor 2.4.6 and codrova-plugin-iosrtc is working for me, just wanna confirm if the webkit issue is actually fixed as imhoffd mentioned, so we can do without the plugin.

@iometrine
Copy link

@karen1au, ok so i let answer @imhoffd answer to you.
But for me we still need to use this plugin because the problem of permission is still there on ios14.4.
We will see the 14.5.

@Sahil624
Copy link

Sahil624 commented Jun 2, 2021

Capacitor Plugin With Native Webrtc would be nice. Just like react-native-webrtc .

@danielehrhardt
Copy link

danielehrhardt commented Jun 4, 2021

Did someone moved the the Native 14.3 WebRTC implementation?

Did worked flawless. I removed iosrtc and set the xCode Version to 12.3

@vikash-rakit
Copy link

I am trying navigator.getUserMedia on a brand new ionic capacitor project (created using cli command) and I am getting NotAllowedError. even navigator.mediaDevices.getUserMedia throws error.

I have set the permission in the info.plist as well.
I see following log

App[XXXX:XXXXX] [plugin] AddInstanceForFactory: No Factory Registered for id <CFUUID 0x6.....>

i am trying on Xcode 12.4 and for ios 14.4. Tried both emulator and phone. Can someone please help.

@iometrine
Copy link

Some news of my side. I migrate from capacitor V3 and for me the version of the plugin 6.0.21 doesn't work but 6.0.20 works.
About ios, it works for me without the cordova-plugin-iosrtc with 14.5 minimum. It doesn't work on 14.3 neither 14.4.

@riderx
Copy link

riderx commented Nov 18, 2021

@danielehrhardt add your plugin to awesome-capacitor if that is useful please take time to star the repo as well :)

@AramKuru
Copy link

AramKuru commented Oct 7, 2024

it is 2024!

@vkuprin
Copy link

vkuprin commented Dec 21, 2024

I believe the only possible workaround is to use a NativeScript community plugin with WebRTC integration or to use cordova-plugin-iosrtc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatible cordova plugin exists An incompatible Cordova plugin exists already plugin proposal
Projects
None yet
Development

No branches or pull requests