I understand that this question has been raised multiple times, but previous inquiries have focused on integrating a third-party dependency in a react-native
app. In my case, the issue stems from my own native code, and I am struggling to resolve it. My current version of react-native
is 0.69.
Here is a snippet of my code found in CealScanQrViewManager.kt:
class CealScanQrViewManager(
private val reactContext: ReactApplicationContext
) : ViewGroupManager<FrameLayout>() {
private val cealScanQrView = "CealScanQrView"
// ...
override fun getName() = cealScanQrView
// ...
}
On the JavaScript side, I have created a CealScanQrViewManager.tsx file:
import {requireNativeComponent} from 'react-native';
export const CealScanQrViewManager = requireNativeComponent(
'CealScanQrViewManager',
);
In App.tsx:
const App = () => {
// ...
const [isCameraPermissionGranted, setIsCameraPermissionGranted] =
useState(false);
// ...
useEffect(() => {
requestCameraPermission();
}, []);
// ...
const requestCameraPermission = async () => {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.CAMERA,
{
title: 'Cool Photo App Camera Permission',
message:
'Cool Photo App needs access to your camera ' +
'so you can take awesome pictures.',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK',
},
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
setIsCameraPermissionGranted(true);
} else {
console.log('Camera permission denied');
}
} catch (err) {
console.warn(err);
}
};
// ...
return (
<SafeAreaView /* ... */>
{/* ... */}
{isCameraPermissionGranted ? (
<CealScanQrViewManager
/* ... */
/>
) : (
<View style={{flex: 1, backgroundColor: 'red'}} />
)}
</SafeAreaView>
);
};
Upon granting camera permission, an error occurs stating:
requireNativeComponent CealScanQrViewManager was not found in UIManager