Cannot read property 'requestPermission' of undefined
See original GitHub issueAn error occurs while accessing permissions.
TypeError: Cannot read property 'requestPermission' of undefined
This error is located at:
in QRCodeScanner (at Scanner.tsx:15)
in QRScanner (at Login.tsx:36)
in RCTView (at View.js:45)
in View (at Login.tsx:33)
What’s happening?
When I add a scanner component to the render.
How can it be reproduced?
import React, { Component } from "react";
import { AppRegistry, Text, TouchableOpacity, Linking } from "react-native";
import QRCodeScanner from "react-native-qrcode-scanner";
import styles from "./Scanner.styles";
class QRScanner extends Component {
error: any;
onSuccess = (e: any) => {
Linking.openURL(e.data).catch(err => (this.error = err));
};
render() {
return (
<QRCodeScanner
onRead={this.onSuccess}
topContent={
<Text style={styles.centerText}>
Go to{" "}
<Text style={styles.textBold}>wikipedia.org/wiki/QR_code</Text> on
your computer and scan the QR code.
</Text>
}
bottomContent={
<TouchableOpacity style={styles.buttonTouchable}>
<Text style={styles.buttonText}>OK. Got it!</Text>
</TouchableOpacity>
}
/>
);
}
}
AppRegistry.registerComponent("default", () => QRScanner);
export default QRScanner;
// in some component
public render() {
return (
<View style={styles.container}>
<QRScanner />
</View>
);
}
I detected error here on step 1.
// const CAMERA_PERMISSION = "camera";
console.log(1)
Permissions.request(CAMERA_PERMISSION).then(response => {
console.log(2)
this.setState({
isAuthorized: response === PERMISSION_AUTHORIZED,
isAuthorizationChecked: true
});
});
If i change "camera"
from const CAMERA_PERMISSION = "camera";
on "ios.permission.CAMERA"
from CAMERA: "ios.permission.CAMERA";
of react-native-permissions types, I achieve some result.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:12
Top Results From Across the Web
Cannot read property getPermissionStatus of undefined
I downgraded React Native to 0.52.0 as that's the last react-native-permissions updated their README and I still get the same error. react- ...
Read more >Notification.requestPermission() - Web APIs - MDN Web Docs
The requestPermission() method of the Notification interface requests permission from the user for the current origin to display notifications.
Read more >cordova-plugin-health/Lobby - Gitter
I get "Uncaught TypeError: Cannot read property 'isAvailable' of undefined" with I try the "navigator.health.isAvailable(successCallback, errorCallback)" ...
Read more >Tizen.ppm undefined, tizen object does exist (web app for TV ...
…but it errors out in console: TypeError: Cannot read property 'requestPermission' of undefined as if the ppm property of the tizen object ...
Read more >react-native-permissions - npm
An unified permissions API for React Native on iOS, Android and Windows. Latest version: 3.6.1, last published: 5 months ago.
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 Free
Top 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
Works great. Thanks!
But you need:
react-native-permissions 2.0.0 exactly, it is up, not work, only with the 2.0.0