Open TemaSM opened 4 years ago
Varient 1 will probably break some of the minor features in the plugin. fullscreen, alerts, console etc.
I don't Variant 2 can work, unless the function is already defined in the JavaScript layer. The android runtime creates a Java wrapper at compile time.
I haven't tried to setup permissions like that in the webview, but I'll see what I can do.
I think, I've solved it on Android, but I need you to test it and if the test is successful, I need a teammate to review the code. This might take a while since, we're working on a new project.
Install @nota/nativescript-webview-ext@6.5.3-mediadevices.0
You also need to install nativescript-permissions
for this to work and add an requestPermissionsEvent
.
We don't want to depend on the nativescript-permissions
, as it is a limited use-case.
webview.on(WebViewExt.requestPermissionsEvent, (args: RequestPermissionsEventData) => {
const wantedPerssions = args.permissions
.map((p) => {
if (p === "RECORD_AUDIO") {
return android.Manifest.permission.RECORD_AUDIO;
}
if (p === "CAMERA") {
return android.Manifest.permission.CAMERA;
}
return p;
})
.filter((p) => !!p);
permissions
.requestPermissions(wantedPerssions)
.then(() => args.callback(true))
.catch(() => args.callback(false));
});
According to https://bugs.webkit.org/show_bug.cgi?id=188360 we cannot add support on iOS
because WKWebView
doesn't support it.
@m-abs could you add it in 8.0.0 ? i have the need for it on android
Hi, thanks for your NS plugin, it's awesome! 👏
I'm trying to implement:
WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)
(link to android docs) to simply grant access to microphone and camera into WebView, but with no success 😢Here's my code snippet (
WebViewExt
'sloadStarted
event handler):As you can see, I tried with two different variants, but no one works. Important notice - I've already added required permissions to my
AndroidManifest.xml
and check & request these permissions during app runtime (before WebView loaded):JS script loaded on page in WebView, still cannot enumerate devices by calling
navigator.mediaDevices.getUserMedia()
, but prototyped native Android app can get access to these devices. Where am I wrong?Hope for your quick reply and thanks in advance 😃