diff --git a/ios/Podfile.lock b/ios/Podfile.lock index c5932121e074..491ec28b59e5 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1169,7 +1169,9 @@ PODS: - React-Core - react-native-blob-util (0.19.4): - React-Core - - react-native-cameraroll (5.4.0): + - react-native-cameraroll (7.4.0): + - glog + - RCT-Folly (= 2022.05.16.00) - React-Core - react-native-config (1.4.6): - react-native-config/App (= 1.4.6) @@ -1938,7 +1940,7 @@ SPEC CHECKSUMS: React-Mapbuffer: 9ee041e1d7be96da6d76a251f92e72b711c651d6 react-native-airship: 6ded22e4ca54f2f80db80b7b911c2b9b696d9335 react-native-blob-util: 30a6c9fd067aadf9177e61a998f2c7efb670598d - react-native-cameraroll: 8ffb0af7a5e5de225fd667610e2979fc1f0c2151 + react-native-cameraroll: 3301d62d45616ee9da55ceed04be8d788c3de3ef react-native-config: 7cd105e71d903104e8919261480858940a6b9c0e react-native-document-picker: 3599b238843369026201d2ef466df53f77ae0452 react-native-geolocation: 0f7fe8a4c2de477e278b0365cce27d089a8c5903 diff --git a/package-lock.json b/package-lock.json index 7d66abc73c13..3a4ed845ceb8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "@kie/mock-github": "^1.0.0", "@onfido/react-native-sdk": "10.6.0", "@react-native-async-storage/async-storage": "1.21.0", - "@react-native-camera-roll/camera-roll": "5.4.0", + "@react-native-camera-roll/camera-roll": "7.4.0", "@react-native-clipboard/clipboard": "^1.13.2", "@react-native-community/geolocation": "^3.0.6", "@react-native-community/netinfo": "11.2.1", @@ -8819,10 +8819,12 @@ } }, "node_modules/@react-native-camera-roll/camera-roll": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@react-native-camera-roll/camera-roll/-/camera-roll-5.4.0.tgz", - "integrity": "sha512-SMEhc+2hQWubwzxR6Zac0CmrJ2rdoHHBo0ibG2iNMsxR0dnU5AdRGnYF/tyK9i20/i7ZNxn+qsEJ69shpkd6gg==", - "license": "MIT", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@react-native-camera-roll/camera-roll/-/camera-roll-7.4.0.tgz", + "integrity": "sha512-y0bVpMJLaFphYvMMx1BsqgMA0kXq9CKxKYNnt4ocUvwJj5Rp4TZ233rzJoDqz1oxd56Tz5f1g+yhYN5RImKl8Q==", + "engines": { + "node": ">= 18.17.0" + }, "peerDependencies": { "react-native": ">=0.59" } diff --git a/package.json b/package.json index 88c2e9a5a520..34d0f5d6c1ac 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "@kie/mock-github": "^1.0.0", "@onfido/react-native-sdk": "10.6.0", "@react-native-async-storage/async-storage": "1.21.0", - "@react-native-camera-roll/camera-roll": "5.4.0", + "@react-native-camera-roll/camera-roll": "7.4.0", "@react-native-clipboard/clipboard": "^1.13.2", "@react-native-community/geolocation": "^3.0.6", "@react-native-community/netinfo": "11.2.1", diff --git a/patches/@react-native-camera-roll+camera-roll+5.4.0.patch b/patches/@react-native-camera-roll+camera-roll+5.4.0.patch deleted file mode 100644 index f0429bc10125..000000000000 --- a/patches/@react-native-camera-roll+camera-roll+5.4.0.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/node_modules/@react-native-camera-roll/camera-roll/android/build.gradle b/node_modules/@react-native-camera-roll/camera-roll/android/build.gradle -index 3f76132..63dc946 100644 ---- a/node_modules/@react-native-camera-roll/camera-roll/android/build.gradle -+++ b/node_modules/@react-native-camera-roll/camera-roll/android/build.gradle -@@ -81,7 +81,9 @@ def findNodeModulePath(baseDir, packageName) { - } - - def resolveReactNativeDirectory() { -- def reactNative = file("${findNodeModulePath(rootProject.projectDir, "react-native")}") -+ def projectDir = this.hasProperty('reactNativeProject') ? this.reactNativeProject : rootProject.projectDir -+ def modulePath = file(projectDir); -+ def reactNative = file("${findNodeModulePath(modulePath, 'react-native')}") - if (reactNative.exists()) { - return reactNative - } diff --git a/patches/@react-native-camera-roll+camera-roll+7.4.0.patch b/patches/@react-native-camera-roll+camera-roll+7.4.0.patch new file mode 100644 index 000000000000..59fdaf904c8e --- /dev/null +++ b/patches/@react-native-camera-roll+camera-roll+7.4.0.patch @@ -0,0 +1,34 @@ +diff --git a/node_modules/@react-native-camera-roll/camera-roll/android/build.gradle b/node_modules/@react-native-camera-roll/camera-roll/android/build.gradle +index 6891fa3..8397f95 100644 +--- a/node_modules/@react-native-camera-roll/camera-roll/android/build.gradle ++++ b/node_modules/@react-native-camera-roll/camera-roll/android/build.gradle +@@ -81,7 +81,9 @@ def findNodeModulePath(baseDir, packageName) { + } + + def resolveReactNativeDirectory() { +- def reactNative = file("${findNodeModulePath(rootProject.projectDir, "react-native")}") ++ def projectDir = this.hasProperty('reactNativeProject') ? this.reactNativeProject : rootProject.projectDir ++ def modulePath = file(projectDir); ++ def reactNative = file("${findNodeModulePath(modulePath, 'react-native')}") + if (reactNative.exists()) { + return reactNative + } +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 4769d28..ef88a07 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,14 @@ static void requestPhotoLibraryAccess(RCTPromiseRejectBlock reject, PhotosAuthor + options.fetchLimit = 1; + PHFetchResult *createdAsset = [PHAsset fetchAssetsWithLocalIdentifiers:@[placeholder.localIdentifier] + options:options]; ++ ++ if (![createdAsset isKindOfClass:[PHAsset class]]) { ++ resolve(@{ ++ @"node": [NSNull null] ++ }); ++ return; ++ } ++ + if (createdAsset.count < 1) { + reject(kErrorUnableToSave, nil, nil); + return; diff --git a/src/libs/fileDownload/index.ios.ts b/src/libs/fileDownload/index.ios.ts index 4990c389fd9f..7960f6c9e4ba 100644 --- a/src/libs/fileDownload/index.ios.ts +++ b/src/libs/fileDownload/index.ios.ts @@ -1,4 +1,5 @@ import {CameraRoll} from '@react-native-camera-roll/camera-roll'; +import type {PhotoIdentifier} from '@react-native-camera-roll/camera-roll'; import RNFetchBlob from 'react-native-blob-util'; import CONST from '@src/CONST'; import * as FileUtils from './FileUtils'; @@ -29,16 +30,16 @@ function downloadFile(fileUrl: string, fileName: string) { * Download the image to photo lib in iOS */ function downloadImage(fileUrl: string) { - return CameraRoll.save(fileUrl); + return CameraRoll.saveAsset(fileUrl); } /** * Download the video to photo lib in iOS */ -function downloadVideo(fileUrl: string, fileName: string): Promise { +function downloadVideo(fileUrl: string, fileName: string): Promise { return new Promise((resolve, reject) => { let documentPathUri: string | null = null; - let cameraRollUri: string | null = null; + let cameraRollAsset: PhotoIdentifier; // Because CameraRoll doesn't allow direct downloads of video with remote URIs, we first download as documents, then copy to photo lib and unlink the original file. downloadFile(fileUrl, fileName) @@ -47,20 +48,17 @@ function downloadVideo(fileUrl: string, fileName: string): Promise { if (!documentPathUri) { throw new Error('Error downloading video'); } - return CameraRoll.save(documentPathUri); + return CameraRoll.saveAsset(documentPathUri); }) .then((attachment) => { - cameraRollUri = attachment; + cameraRollAsset = attachment; if (!documentPathUri) { throw new Error('Error downloading video'); } return RNFetchBlob.fs.unlink(documentPathUri); }) .then(() => { - if (!cameraRollUri) { - throw new Error('Error downloading video'); - } - resolve(cameraRollUri); + resolve(cameraRollAsset); }) .catch((err) => reject(err)); });