I am using Expo with React Native for my app. upon clikcing on a button, i want the user to have the ability to upload multiple pdf files. I am using expo and the expo go app (on a physical device and on a simulator) to test code.
The issue now is that every time I want to open the Document Picker on IOS, I briefly see the document selector and then it disappears and I can't pick any documents.
This is the code I use:
try { const result = await DocumentPicker.getDocumentAsync({ type:'*/*', copyToCacheDirectory: true, multiple: false }); if (result.type === 'success') { console.log('Document picked:', result); } else { console.log('Document picking canceled'); } console.log('result', JSON.stringify(result))} catch (err) { console.log('error', err)}
This is how my app.json file looks like:
{"expo": {"name": "My name","scheme": "example-app","slug": "example-app","version": "1.0.11","orientation": "portrait","icon": "./assets/resized_icon.png","userInterfaceStyle": "light","splash": {"image": "./assets/logo.png","resizeMode": "contain","backgroundColor": "#ffffff" },"assetBundlePatterns": ["**/*" ],"ios": {"googleServicesFile": "./GoogleService-Info.plist","supportsTablet": true,"icon": "./assets/logo_apple_format.png","bundleIdentifier": "********","usesIcloudStorage": true,"infoPlist": {"NSLocationAlwaysUsageDescription": "Wir brauchen Zugriff auf den Ort, um die Applikation optimal laufen lassen zu können.","NSPhotoLibraryUsageDescription": "Wir brauchen Zugriff auf die Galerie, um Bilder für die Beantragung der Rückerstattung hochzuladen.","NSCameraUsageDescription": "Wir brauchen Zugriff auf die Kamera, um Bilder für die Beantragung der Rückerstattung hochzuladen.","NSDocumentPickerUsageDescription": "Wir brauchen Zugriff auf die Dokumente, um Dokumente hochzuladen für die Beantragung der Rückerstattung." } },"android": {"googleServicesFile": "./google-services.json","adaptiveIcon": {"foregroundImage": "./assets/resized_icon.png","backgroundColor": "#ffffff" },"package": "packageid","versionCode": 11,"permissions": ["android.permission.CAMERA","android.permission.WRITE_EXTERNAL_STORAGE" ] },"web": {"favicon": "./assets/resized-icon.png" },"plugins": ["expo-router","@react-native-firebase/app","@react-native-firebase/auth", ["expo-document-picker", {"iCloudContainerEnvironment": "Production" } ], ["expo-build-properties", {"ios": {"useFrameworks": "static","deploymentTarget": "13.4" } } ] ],"extra": {"router": {"origin": false },"eas": {"projectId": "*********" } },"owner": "*********" }}
I have followed the documentation to the best of my abilities and yet the document picker doesn't work on a physical ios device or on a simulator.
Any help will be greatly appreciated.
EDIT: I have tested it further and found out that the issue is that i call the function within a modal. Outside of it, it works. How can I make it work within a modal?