This happens in android build of ionic app. I am using a iframe to test the getUserMedia. The demo page of webrtc gives me "GetUserMedia : Not Allowed Error". I have given all permissions in AndroidManifest.xml, but still couldn't access the camera. is there anything else needs to be done, for getting camera access for external website?
home.html
<ion-content class= 'padding has-subheader'>
<iframe class= 'webPage' name= "eventsPage" src="https://webrtc.github.io/samples/src/content/getusermedia/gum/">
</iframe>
</ion-content>
config.xml
<plugin name="cordova-plugin-statusbar" spec="2.4.2" />
<plugin name="cordova-plugin-device" spec="2.0.2" />
<plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^2.0.0" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
<plugin name="cordova-plugin-camera" spec="^4.0.3" />
<plugin name="android-camera-permission" spec="^1.0.0" />
<plugin name="cordova-plugin-media" spec="^5.0.2" />
<plugin name="cordova-opentok-android-permissions" spec="^1.0.1" />
<plugin name="cordova.plugins.diagnostic" spec="^4.0.10" />
<plugin name="cordova-plugin-android-permissions" spec="^1.0.0" />
<plugin name="cordova-plugin-media-capture" spec="^3.0.2" />
<plugin name="cordova-plugin-compat" spec="^1.2.0" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<engine name="android" spec="7.0.0" />
Flagged as a duplicate of: Does getUserMedia works in ionic-webview in Android app?
Nevertheless I have copied and pasted my answer below
Update - 19/11/2020
WKWebView can use getUserMedia in iOS 14.3 beta 1.
Update - 04/11/2018 - Working Ionic example
As promised I had a crack at this today. To answer your question now in full: Yes you can access getUserMedia inside of ionic on Android.
See my GitHub project here for a working example and for screenshots.
See this feature branch here which successfully tests getUserMedia inside of an iframe
Steps involved:
You can also see alternative versions of this for React Native, native Android and Cordova.
As of this update support for iOS is still a no due to Apple security restrictions on WKWebView and UIWebView.
Iframes: To make sure getUserMedia works inside of them make sure you:
<iframe allow="camera; microphone">Please read the following for more info on iframe features:
Yes, it theoretically can work. See my example below on how to do it in Android. For iOS this isn't currently possible due to the limitations of WKWebView. I have linked to a StackOverFlow question below on how people are achieving this on Cordova which Ionic is based off.
The core main steps which need to be achieved to get getUserMedia working on Android regardless of framework are:
The issue you are specifically facing is 4. or 5. It looks like the project gets you that far. The permission error is most likely down to the Chrome WebView your app is using doesn't override the permission, and/or it is and the user hasn't manually enabled the permission.
Thus within the Ionic framework you need to extend its Browser to get access to the override onRequestPermissionsResult. To do this you need to make a Cordova plugin and then create the Ionic bindings.
More reading about this for similar frameworks can be found here: