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 requestReadContactPermission (callback) {
try {
Permissions.requestPermission('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 requestCameraPermission (callback) {
try {
Permissions.requestPermission('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)
}
}
export async function getPosition() {
// Permissions.openSettings();
if (Platform.OS === 'ios') {
const status = await Permissions.requestPermission('location');
if (status !== 'authorized') {
// No location permission. Let's ignore it for now since the app will work fine
// But if we ever change our mind, we can prompt and run:
// Permissions.openSettings();
throw new Error('No location permissions');
}
// Otherwise have authorized permissions now, let's get their location!
}
return await getCurrentPosition();
}
export async function getPosition() {
// Permissions.openSettings();
if (Platform.OS === 'ios') {
const status = await Permissions.requestPermission('location');
if (status !== 'authorized') {
// No location permission. Let's ignore it for now since the app will work fine
// But if we ever change our mind, we can prompt and run:
// Permissions.openSettings();
throw new Error('No location permissions');
}
// Otherwise have authorized permissions now, let's get their location!
}
return await getCurrentPosition();
}
getPermission() {
Permissions.requestPermission('location')
.then(response => {
// dispatch response
this.props.dispatch(setPermission(response));
// if authorized, act
if (response === 'authorized') {
this.startLocationWatch();
}
})
.catch((error) => {
logger.log('Error requesting Permission: ' + error);
return null;
});
},
_requestCamera() {
Permissions.requestPermission('camera')
.then(response => {
//returns once the user has chosen to 'allow' or to 'not allow' access
//response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
console.log("camera response after req", response)
});
}
_requestMicrophone() {
_requestMicrophone() {
Permissions.requestPermission('microphone')
.then(response => {
//returns once the user has chosen to 'allow' or to 'not allow' access
//response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
console.log("microphone response after req", response)
});
}