basic question here that I have been unable to get an answer from.
Does navigator.mediaDevices.getUserMedia work in a hybrid app?
Let me expand on this a bit.
I have a hybrid app currently that I am trying to transition to use mainly web apis, while for the most part everything is working as expected I am unable to get the camera to be accessable in an 'app' form.
When I run the code
navigator.mediaDevices.getUserMedia
I get back one of two errors (depending on the hybrid framework I use)
Now, item one would indicate that the user has not 'allowed' permissions to the actual camera but the catch is, I never get prompted to grant permissions in-app.
For number two, that would seem to indicate that the stream is already in use (have seen some stating this too can be related to permissions so I'm leaning toward that assumption)
So I guess back to the question at hand and that is, is this even possible in a hybrid app? I have seen many of similar questions with similar Dom messages but non seem to have an answer in the sense of is it even possible? I have seen some mention setting the 'feature-policy' headers but in the context of a hybrid app, running a localhost how or where is this set?
Anyhow, just wanted to ask and see if anyone else has been successful in doing this or do we need to use the native plugins for this?
Thanks again!
Yes, it’s possible to use it, I have a sample app that uses it https://github.com/jcesarmobile/can-i-use-on-webview/tree/master/getusermedia
You have to provide certain permissions on android and add certain usage descriptions on iOS.
The example app only provides camera permission/usage description because it doesn’t capture audio.
Doesn’t work on all iOS versions, I think the first version to support it was 14.5.