mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2025-12-23 22:18:36 -05:00
* Patch camera roll to not ask for readwrite after addonly granted * Only request add permission from cameras
32 lines
1.5 KiB
Diff
32 lines
1.5 KiB
Diff
diff --git a/node_modules/@react-native-camera-roll/camera-roll/ios/RNCCameraRoll.mm b/node_modules/@react-native-camera-roll/camera-roll/ios/RNCCameraRoll.mm
|
|
index b8f2aa2..aa0df68 100644
|
|
--- a/node_modules/@react-native-camera-roll/camera-roll/ios/RNCCameraRoll.mm
|
|
+++ b/node_modules/@react-native-camera-roll/camera-roll/ios/RNCCameraRoll.mm
|
|
@@ -207,6 +207,26 @@ RCT_EXPORT_METHOD(saveToCameraRoll:(NSURLRequest *)request
|
|
}
|
|
} completionHandler:^(BOOL success, NSError *error) {
|
|
if (success) {
|
|
+ // If the write succeeded but we don't have readwrite permission, that
|
|
+ // means we have addonly permission and we cannot read the file we
|
|
+ // just created to construct a response
|
|
+ if (@available(iOS 14, *)) {
|
|
+ PHAuthorizationStatus readWriteAuthStatus = [PHPhotoLibrary authorizationStatusForAccessLevel:PHAccessLevelReadWrite];
|
|
+ if (readWriteAuthStatus != PHAuthorizationStatusAuthorized) {
|
|
+ NSDictionary *addOnlyResponse = @{
|
|
+ @"node": @{
|
|
+ @"id": placeholder.localIdentifier,
|
|
+ @"type": options[@"type"],
|
|
+ @"image": @{
|
|
+ @"uri": @"placeholder/readWritePermissionNotGranted"
|
|
+ }
|
|
+ }
|
|
+ };
|
|
+ resolve(addOnlyResponse);
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+
|
|
PHFetchOptions *options = [PHFetchOptions new];
|
|
options.includeHiddenAssets = YES;
|
|
options.includeAllBurstAssets = YES;
|