Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function checkReadContactPermission (callback) {
try {
Permissions.getPermissionStatus('contacts').then(response => {
let granted = false
if (response === 'authorized') {
granted = true
}
// response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
return callback(null, granted)
})
} catch (err) {
console.error(err)
callback(err, null)
}
}
export async function checkCameraPermission (callback) {
try {
Permissions.getPermissionStatus('camera').then(response => {
let granted = false
if (response === 'authorized') {
granted = true
}
// response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
return callback(null, granted)
})
} catch (err) {
console.error(err)
callback(err, null)
}
}
checkLocationPermission() {
const { dispatch } = this.props;
// preload permission and dispatch immediately
Permissions.getPermissionStatus('location')
.then(response => {
dispatch(setPermission(response));
if (response !== 'authorized') {
this.getPermission();
}
});
},
componentDidMount() {
Permissions.getPermissionStatus('camera')
.then(response => {
//response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
console.log('permissions response', response)
if (response === 'authorized' ){
console.log("camera authorized")
} else {
this._requestCamera()
}
});
Permissions.getPermissionStatus('microphone')
.then(response => {
//response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
console.log('micro response', response)
if (response === 'authorized' ){
console.log("yay")
} else {
componentDidMount() {
Permissions.getPermissionStatus('camera')
.then(response => {
//response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
console.log('permissions response', response)
if (response === 'authorized' ){
console.log("camera authorized")
} else {
this._requestCamera()
}
});
Permissions.getPermissionStatus('microphone')
.then(response => {
//response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
console.log('micro response', response)
if (response === 'authorized' ){
console.log("yay")
} else {
this._requestMicrophone()
}
});
console.log("trying to start")
}
_toggleLive = () => {
export async function hasLocationPermission() {
const status = await Permissions.getPermissionStatus('location');
return status === Permissions.StatusAuthorized;
}