Not opening Camera on reactnative-webview and no pop-up message for camera open.
See original GitHub issuethis url asks camera open using getusermedia() in webapp js, and I tried to open this url in react-native webview but not showing any pop-up message to open the camera on webview(expo app). Please help me on the same.
(I tried using snack.expo, but no luck so far).
Tried this two logic as well, but no success:
import React, { Component, useState, useEffect } from 'react';
import { Text, View, StyleSheet, WebView } from 'react-native';
import { Constants } from 'expo';
import { TouchableOpacity } from 'react-native';
import { Camera } from 'expo-camera';
import * as Permissions from 'expo-permissions';
export default class App extends Component {
// const [hasPermission, setHasPermission] = useState(null);
async componentDidMount() {
const { status } = await Permissions.askAsync(Permissions.CAMERA);
this.setState({
hasCameraPermission: status === 'granted',
});
}
render() {
const url = ''https://turncameraon.com/';
return (
<WebView
source={{
uri: url,
}}
startInLoadingState
scalesPageToFit
javaScriptEnabled
style={{ flex: 1 }}
/>
);
}
}
Another logic , I tried:
import React, { useState, useEffect } from 'react';
import { Text, View, TouchableOpacity } from 'react-native';
import { Camera } from 'expo-camera';
import { WebView } from 'react-native-webview';
export default function App() {
const [hasPermission, setHasPermission] = useState(null);
const [type, setType] = useState(Camera.Constants.Type.back);
const url = 'https://turncameraon.com/';
useEffect(() => {
(async () => {
const { status } = await Camera.requestPermissionsAsync();
setHasPermission(status === 'granted');
})();
}, []);
if (hasPermission === null) {
return <View />;
}
if (hasPermission === false) {
return <Text>No access to camera</Text>;
}
return (
<WebView
source={{
uri: url,
}}
startInLoadingState
scalesPageToFit
javaScriptEnabled
style={{ flex: 1 }}
/>
);
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:5
Top Results From Across the Web
no popup for android webview to upload files or open camera
Try this code: public class MainActivity extends Activity { private RelativeLayout mLayout; private ProgressBar progressBar; private WebView ...
Read more >React Native WebView: A complete guide
React Native WebView renders web content in a native view. Learn some of its tricks and features that you can use to your...
Read more >react native webView | react native tutorial - YouTube
in this tutorial you will learn 1- The Component State And Lifecycle 2- Check Internet connectivity by NetInfo3- Use the WebView Component4- ...
Read more >Reactnative webview camera permission
Please follow the below steps to add the permission in iOS project to use the camera. Open the project CameraExample -> ios ->...
Read more >React Native WebView - Loading Websites and HTML in ...
In other words, a web view allows us to open the web URLs inside the app interface. While React Native provides us with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@vasanthhr any update on this am facing almost same issue 🤔 ?
Does someone find a solution about this ?