question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not opening Camera on reactnative-webview and no pop-up message for camera open.

See original GitHub issue

this 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:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:5

github_iconTop GitHub Comments

14reactions
FadiAboMsalamcommented, Apr 21, 2020

@vasanthhr any update on this am facing almost same issue 🤔 ?

6reactions
martinfrouincommented, Oct 1, 2020

Does someone find a solution about this ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found