I am trying to access ios permissions using expo it works on expo go ios simulator and a real device but doesnt work on development build. I researched and i think it is because i dont have an apple developer membership account but i am not a 100% sure. Here is my error
WARN The native view manager required by name (ExpoCamera) from NativeViewManagerAdapter isn’t exported by expo-modules-core. Views of this type may not render correctly. Exported view managers: [RNCSafeAreaProvider, ExpoLinearGradient].
ERROR Error: Cannot find native module ‘ExpoCamera’, js engine: hermes
ERROR Invariant Violation: “main” has not been registered. This can happen if:
- Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
- A module failed to load due to an error and
AppRegistry.registerComponent
wasn’t called., js engine: hermes
I am trying to access camera, microphone and media gallery and below is the code on how i handled it
import React, { useState, useEffect, useRef } from 'react';
import { View, Text, TouchableOpacity, Image, StyleSheet, Alert, Dimensions } from 'react-native';
import { Camera, CameraType } from 'expo-camera';
import * as ImagePicker from 'expo-image-picker';
import { Ionicons } from '@expo/vector-icons';
const ProfilePicture: React.FC<{ navigation: any }> = ({ navigation }) => {
interface cameraStates {
hasCameraPermission : boolean | null,
profileImage: string | null
}
const [states, setStates] = useState<cameraStates>({
hasCameraPermission: null,
profileImage: null
})
const cameraRef = useRef<Camera>(null);
useEffect(() => {
(async () => {
const { status } = await Camera.requestCameraPermissionsAsync();
setStates({...states, hasCameraPermission : status === 'granted'});
})();
}, []);
const handleTakePicture = async () => {
if (cameraRef.current) {
const photo = await cameraRef.current.takePictureAsync();
setStates({...states, profileImage: photo.uri});
}
};
const handleChooseFromGallery = async () => {
const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync();
if (permissionResult.granted === false) {
Alert.alert("Permission to access camera roll is required!");
return;
}
const result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: true,
aspect: [1, 1],
quality: 1,
});
if (!result.canceled && result.assets) {
setStates({...states, profileImage: result.assets[0].uri});
}
};
const handleRemoveImage = () => {
setStates({...states, profileImage: null});
};
const handleNext = () => {
if (states.profileImage) {
navigation.navigate("ConnectContact");
}
};
if (states.hasCameraPermission === null) {
return <View />;
}
if (states.hasCameraPermission) {
return <Text>No access to camera</Text>;
}
I have also included the couple information in my info.plist
<key>NSCameraUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your camera.</string>
<key>NSContactsUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your contacts</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to use the microphone</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to save photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your photos.</string>
Also included these in my app.json
"plugins": [
[
"expo-camera",
{
"cameraPermission": "Allow $(PRODUCT_NAME) to access your camera."
}
],
[
"expo-media-library",
{
"photosPermission": "Allow $(PRODUCT_NAME) to access your photos.",
"savePhotosPermission": "Allow $(PRODUCT_NAME) to save photos.",
"isAccessMediaLocationEnabled": true
}
]
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.iseoluwa411.mySocialMediaApp",
"infoPlist": {
"NSPhotoLibraryUsageDescription": "This app requires access to the photo library to use photos for display pictures.",
"NSCameraUsageDescription": "This app requires access to the camera to take photos for display pictures."
}
Please how can this error be fixed in development mode. Works perfectly well in expo go