mirror of
https://github.com/status-im/react-native-webview.git
synced 2026-08-31 11:41:08 +00:00
Don't allow camera and mic permissions by default. Notify user about permission request
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
Platform,
|
||||
} from 'react-native';
|
||||
|
||||
import Permission from './examples/Permission';
|
||||
import Alerts from './examples/Alerts';
|
||||
import Scrolling from './examples/Scrolling';
|
||||
import Background from './examples/Background';
|
||||
@@ -19,6 +20,14 @@ import Injection from './examples/Injection';
|
||||
import LocalPageLoad from './examples/LocalPageLoad';
|
||||
|
||||
const TESTS = {
|
||||
Permission: {
|
||||
title: 'Permission',
|
||||
testId: 'permission',
|
||||
description: 'Permission tests',
|
||||
render() {
|
||||
return <Permission />;
|
||||
},
|
||||
},
|
||||
Alerts: {
|
||||
title: 'Alerts',
|
||||
testId: 'alerts',
|
||||
@@ -113,6 +122,11 @@ export default class App extends Component<Props, State> {
|
||||
</TouchableOpacity>
|
||||
|
||||
<View style={styles.testPickerContainer}>
|
||||
<Button
|
||||
testID="testType_permission"
|
||||
title="Permission"
|
||||
onPress={() => this._changeTest('Permission')}
|
||||
/>
|
||||
<Button
|
||||
testID="testType_alerts"
|
||||
title="Alerts"
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import React, {Component} from 'react';
|
||||
import {Text, View} from 'react-native';
|
||||
|
||||
import WebView from 'react-native-webview';
|
||||
|
||||
type Props = {};
|
||||
type State = {};
|
||||
|
||||
export default class Permission extends Component<Props, State> {
|
||||
state = {};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={{ height: 120 }}>
|
||||
<WebView
|
||||
ref={(ref) => (this.webview = ref)}
|
||||
onPermissionRequest={(event) => {
|
||||
console.log("!!! JS: onPermissionRequest, event: ", event.nativeEvent);
|
||||
this.webview.answerPermissionRequest(false, event.nativeEvent.resources );
|
||||
}}
|
||||
source={{uri: 'https://fatal0.netlify.app/android/webviewvideo.html'}}
|
||||
automaticallyAdjustContentInsets={false}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user