Don't allow camera and mic permissions by default. Notify user about permission request

This commit is contained in:
Volodymyr Kozieiev
2020-08-03 11:18:45 +03:00
parent 3bef57fcf8
commit f7a3d58b2f
23 changed files with 264 additions and 78 deletions
+17 -1
View File
@@ -58,6 +58,13 @@ var __rest = (this && this.__rest) || function (s, e) {
}
return t;
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
import React from 'react';
import { Image, requireNativeComponent, UIManager as NotTypedUIManager, View, NativeModules, findNodeHandle, } from 'react-native';
import BatchedBridge from 'react-native/Libraries/BatchedBridge/BatchedBridge';
@@ -128,6 +135,9 @@ var WebView = /** @class */ (function (_super) {
_this.injectJavaScript = function (data) {
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().injectJavaScript, [data]);
};
_this.answerPermissionRequest = function (allow, resources) {
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().answerPermissionRequest, __spreadArrays([allow], (resources || [])));
};
/**
* We return an event with a bunch of fields including:
* url, title, loading, canGoBack, canGoForward
@@ -197,6 +207,12 @@ var WebView = /** @class */ (function (_super) {
onMessage(event);
}
};
_this.onPermissionRequest = function (event) {
var onPermissionRequest = _this.props.onPermissionRequest;
if (onPermissionRequest) {
onPermissionRequest(event);
}
};
_this.onLoadingProgress = function (event) {
var onLoadProgress = _this.props.onLoadProgress;
var progress = event.nativeEvent.progress;
@@ -247,7 +263,7 @@ var WebView = /** @class */ (function (_super) {
var onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(this.onShouldStartLoadWithRequestCallback,
// casting cause it's in the default props
originWhitelist, onShouldStartLoadWithRequestProp);
var webView = (<NativeWebView key="webViewKey" {...otherProps} messagingEnabled={typeof onMessage === 'function'} messagingModuleName={this.messagingModuleName} onLoadingError={this.onLoadingError} onLoadingFinish={this.onLoadingFinish} onLoadingProgress={this.onLoadingProgress} onLoadingStart={this.onLoadingStart} onHttpError={this.onHttpError} onMessage={this.onMessage} onShouldStartLoadWithRequest={onShouldStartLoadWithRequest} ref={this.webViewRef}
var webView = (<NativeWebView key="webViewKey" {...otherProps} messagingEnabled={typeof onMessage === 'function'} messagingModuleName={this.messagingModuleName} onLoadingError={this.onLoadingError} onLoadingFinish={this.onLoadingFinish} onLoadingProgress={this.onLoadingProgress} onPermissionRequest={this.onPermissionRequest} onLoadingStart={this.onLoadingStart} onHttpError={this.onHttpError} onMessage={this.onMessage} onShouldStartLoadWithRequest={onShouldStartLoadWithRequest} ref={this.webViewRef}
// TODO: find a better way to type this.
source={resolveAssetSource(source)} style={webViewStyles} {...nativeConfig.props}/>);
return (<View style={webViewContainerStyle}>