Does getUserMedia works in ionic-webview in IOS app?

I’m trying to use peerjs with using ionic 5 with capacitor and angular9. All works on android and on the web. But when i build the app on ios, I reveice an " notallowederror " at the line “navigation.getUsermedia”

getMedia() {
    navigator.getUserMedia({ audio: true, video: true }, (stream) => {
      this.handleSuccess(stream);
    }, (error) => {
      this.handleError(error);
    });
  }

Any idea ?

Apparently ios 14.3 and 14.4 still does not allow getusermedia.
On the other hand there is an iosrtc cordova plugin which would allow to obtain the stream.
So do you know if I can use this cordova plugin in an ionic capacitor application?
And if yes how ?

getUserMedia is now supported on iOS/iPadOS 14.5 (beta)

you can also use the cordova plugin, just install it and follow the plugin usage instructions/docs

Hello @jcesarmobile ,
Thank you for your answer.

I need to install this:

or this ?

I don’t find the instructions for capacitor .
Can you help me?
Best regards

I have not used any of those, the cordova plugin has a sample app linked in their repository and it works fine in Capacitor, but I just ran the app, didn’t use the plugin or their API other than adding Capacitor to their sample app and running.
I have not tried the Capacitor one.

Which cordova plugin are you talking about ?

you have linked 2, one has capacitor in the name, so I thought it was a capacitor plugin

so the one I refer by the cordova plugin is GitHub - cordova-rtc/cordova-plugin-iosrtc: Cordova iOS plugin exposing the WebRTC W3C API

In their readme they have a “Sample app” section which points to a sample app, that’s what I tested with Capacitor and worked

How did you do ?
Because i have an existing app using capacitor and we can’t install a plugin cordova when we use capacitor

to install cordova plugins in Capacitor projects you just need to npm install them

When i install the plugin iosrtc, i can’t pass the first command:
node ios_arch.js --extract
I have an error

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 ?

Finally I found the solution. The plugin iosrtc works with capacitor.
We just need to add the code below in the podfile:

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

If that can help someone. :slight_smile:
Thanks to all