This code works fine in android devices, but in ios the picker/camera open for few seconds and then automatically closed.
any help?
_openCamera = async () =>{
this._toggleModal(false);
let permission = await this._cameraPermission()
if(permission){
let result = await ImagePicker.launchCameraAsync({
allowsEditing: true,
aspect: [3, 4]
})
console.log(result);
this._uploadPhoto(result)
} else {
this.refs.popupComponent.showPopupMessage("Need Permission", "Close");
console.log("Need Permission")
}
}
_cameraPermission = async () => {
status = await Permissions.getAsync(Permissions.CAMERA);
let statusCamera = status.status;
console.log("statusCameraRoll: ", statusCamera);
if (statusCamera !== "granted") {
console.log("Requesting Notification Permissions");
status = await Permissions.askAsync(Permissions.CAMERA);
statusCamera = status.status;
if(statusCamera != '"granted"')
return false
else {
let status_new = await Permissions.getAsync(Permissions.CAMERA_ROLL);
let statusCameraRoll = status_new.status;
if (statusCameraRoll !== "granted") {
status_new = await Permissions.askAsync(Permissions.CAMERA_ROLL);
statusCameraRoll = status_new.status
if (statusCameraRoll !== "granted")
return false
else
return true
}
else
return true
}
}
else {
let status_new = await Permissions.getAsync(Permissions.CAMERA_ROLL);
let statusCameraRoll = status_new.status;
if (statusCameraRoll !== "granted") {
status_new = await Permissions.askAsync(Permissions.CAMERA_ROLL);
statusCameraRoll = status_new.status
if (statusCameraRoll !== "granted")
return false
else
return true
}
else
return true
}
}
_picClickHandler = async () => {
this._toggleModal(false);
let permission = await this._galleryPermission()
setTimeout
if(permission){
let result = ImagePicker.launchImageLibraryAsync({
aspect: [4, 3],
base64: false,
});
console.log(result);
this._uploadPhoto(result)
} else {
this.refs.popupComponent.showPopupMessage("Need Permission", "Close");
console.log("Need Permission")
}
};
_galleryPermission = async () => {
status = await Permissions.getAsync(Permissions.CAMERA_ROLL);
let statusCameraRoll = status.status;
console.log("statusCameraRoll: ", statusCameraRoll);
if (statusCameraRoll !== "granted") {
console.log("Requesting Notification Permissions");
status = await Permissions.askAsync(Permissions.CAMERA_ROLL);
statusCameraRoll = status.status;
if(statusCameraRoll != '"granted"')
return false
else
return true
}
else
return true
}```
APP.JSON
{
"ios": {
"bundleIdentifier": "com.developtech.workfamProd",
"infoPlist": {
"NSCameraUsageDescription": "This allows us to use your camera to provide you certain features like uploading your Workfam profile picture, sharing selected photos with your employer and tagging fellow colleagues.",
"NSPhotoLibraryUsageDescription": "This allows us to use your photo library to provide you certain features like uploading your Workfam profile picture, sharing selected photos with your employer and tagging fellow colleagues."
}
},
"android": {
"package": "com.developtech.workfam",
"versionCode": 4,
"googleServicesFile": "./google-services.json",
"permissions": [
"CAMERA",
"CAMERA_ROLL",
"READ_INTERNAL_STORAGE",
"READ_EXTERNAL_STORAGE",
"WRITE_EXTERNAL_STORAGE"
]
}
}