mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-04-18 05:49:24 -04:00
* Replace our fork of react-native-camera-roll with latest published npm version * Update package-lock.json * Update Podfile.lock * Create @react-native-camera-roll+camera-roll+7.10.2.patch Copying over commits from our fork of camera-roll into a patch-package patch file. This corresponds to these two commits: 1.) "fix: add a stub URI after save w/ add-only permission (#1) Attempting the fetch the URI of the newly-created photo requires PHOTO LIBRARY permission, which results in an unexpected permission prompt. This prevents that from happening by returning a stub URI which hopefully makes it clear why it's not a real URI."47b39c3d9d2.) "feat: optionally save location when saving photo in iOS"c49afe441e
87 lines
4.3 KiB
Diff
87 lines
4.3 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 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(
|