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 d63f1a7..7cbea21 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 @@ -201,6 +201,18 @@ static void requestPhotoLibraryAccess(RCTPromiseRejectBlock reject, PhotosAuthor assetRequest = [PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL:inputURI]; } } + if (options[@"latitude"] && options[@"longitude"]) { + double latitude = [[options objectForKey:@"latitude"] doubleValue]; + double longitude = [[options objectForKey:@"longitude"] doubleValue]; + double altitude = [[options objectForKey:@"altitude"] doubleValue]; + double horizontalAccuracy = [[options objectForKey:@"horizontalAccuracy"] doubleValue]; + double verticalAccuracy = [[options objectForKey:@"verticalAccuracy"] doubleValue]; + assetRequest.location = [[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) + altitude:altitude + horizontalAccuracy:horizontalAccuracy + verticalAccuracy:verticalAccuracy + timestamp:[NSDate now]]; + } placeholder = [assetRequest placeholderForCreatedAsset]; if (![options[@"album"] isEqualToString:@""]) { photosAsset = [PHAsset fetchAssetsInAssetCollection:collection options:nil]; @@ -209,6 +221,25 @@ static void requestPhotoLibraryAccess(RCTPromiseRejectBlock reject, PhotosAuthor } } 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; diff --git a/node_modules/@react-native-camera-roll/camera-roll/lib/module/CameraRoll.js b/node_modules/@react-native-camera-roll/camera-roll/lib/module/CameraRoll.js index 6735305..7fd78f2 100644 --- a/node_modules/@react-native-camera-roll/camera-roll/lib/module/CameraRoll.js +++ b/node_modules/@react-native-camera-roll/camera-roll/lib/module/CameraRoll.js @@ -84,6 +84,7 @@ export class CameraRoll { if (['mov', 'mp4'].indexOf(fileExtension.toLowerCase()) >= 0) type = 'video';else type = 'photo'; } return RNCCameraRoll.saveToCameraRoll(tag, { + ...options, type, album }); diff --git a/node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll.ts b/node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll.ts index 195687f..bae70a6 100644 --- a/node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll.ts +++ b/node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll.ts @@ -174,6 +174,11 @@ export type PhotoIdentifiersPage = { export type SaveToCameraRollOptions = { type?: 'photo' | 'video' | 'auto'; album?: string; + latitude?: number; + longitude?: number; + altitude?: number; + horizontalAccuracy?: number; + verticalAccuracy?: number; }; export type GetAlbumsParams = { @@ -273,7 +278,7 @@ export class CameraRoll { type = 'video'; else type = 'photo'; } - return RNCCameraRoll.saveToCameraRoll(tag, {type, album}); + return RNCCameraRoll.saveToCameraRoll(tag, {...options, type, album}); } static saveToCameraRoll(