react-native-cameraroll: iOS - Photo Library Add Only permission throws unknown error native module
Scenario:
- Fresh app installation
- Save a photo using the
save()method - Photo Library Permission will be requested
- Choose “Keep Add Only”
- Error will be thrown:
unknown error native module - The photo is saved to the Photo Library.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 17
Same here, and after some debugging I think this error is thrown when the lib tries to fetch the newly created asset here
with only
Add onlypermissioncreatedAssetbecame aPHUnauthorizedFetchResultThat’s why we can still see the photo saved in the Photo Library and the camera-roll lib still throw an error.EDIT : as a temporary workaround I’m using patch-package to check createdAsset kind
I tried this comment but didn’t work because
if (createdAsset.count < 1)is true and the patched lines are not reached. I ended up skipping fetching assets if access level is “Add Only”.@react-native-camera-roll/camera-roll@7.8.3
The following patch fixed my issue, hopefully it fixes yours too
I used this comment as reference, except the condition was wrong since
createdAssetis an array ofPHFetchResultso the condition always evaluates tofalseeven when the user had provided full access and we had data increatedAssetProbably not related but I started getting this error on
7.4.0on production release only, on simulator it works just fine.Click me