0

I use expo document picker which works perfectly fine on android but on IOS, it does not work. I only get an option to open icloud and cannot browse through the device to pick a document.

 const documentFile = await DocumentPicker.getDocumentAsync({
      type: ["image/*", "application/pdf"]
    })

I also tried using documentPicker from react-native-document-picker but when I use documentPicker.pick it says, documentPicker is undefined. cannot access method of undefined object.

const documentFile = await DocumentPicker.pick({
      presentationStyle: 'fullScreen'
    });

I tried running react-native link after npm install and double checked the import statement. But, none of it resolved the problem.

screen 1 upon clicking browse

screen 2 Cannot see photos or image folder

catBuddy
  • 367
  • 1
  • 3
  • 15

2 Answers2

1

I think react-native-document-picker can not pick image from iOS now. You need to use react-native-image-picker.

See this issue https://github.com/rnmods/react-native-document-picker/issues/236

Habibur Rahman
  • 424
  • 7
  • 19
0

Can you share image of the document picker view of your IOS? Cause I think your code of expo document picker is fine.

In the IOS document picker, it may take you to the iCloud file page, you need to click the Browse button (on top left side). Then you will see all the location and I think you may find you files there.

EDIT Maybe you can change the code as below:

type: ["*/*"],

And make sure you already have any PDF files on that phone.

Lewis
  • 41
  • 5
  • I can click on browse but however I cannot see any subfolders after I select 'on my iphone' . See added screenshots in question. It does not give an option to select photos folder. – catBuddy Jul 14 '22 at 07:38
  • Can you find your subfolders when you open "File" on your iPhone home screen? – Lewis Jul 14 '22 at 07:45
  • I just edit my answer, i have you may take a look and try this again – Lewis Jul 14 '22 at 07:53
  • No, I double checked. When I open File on iphone, I do not see "photos" there – catBuddy Jul 15 '22 at 04:34
  • Can you find your"photos" when you open "File" on your iPhone home screen? If not, that's mean you didn't store any photos to the "File". And why are you using document picker to get image... – Lewis Jul 15 '22 at 05:15
  • Images are not store in "File", please clarify what are you going to do and figure out how to use iPhone first. – Lewis Jul 15 '22 at 05:25
  • I want to be able to open photos upon opening of document picker. But you write that document picker is not an appropriate choice for get image. What I want to do is be able to choose either a pdf or image from UI on iOS and i am using react native with expo. So i thought expo document picker is the right choice .. please suggest ? – catBuddy Jul 15 '22 at 08:28
  • You can think about some well-known chat app like "WhatsApp" or "Signal", the way they did is separate the sending doc & image into two button. And I think this is a proper way. In expo, you may use Image Picker for picking image – Lewis Jul 15 '22 at 09:03
  • That sounds like a workaround. to try for sure. But, Document Picker from expo does provide support for various file types among which I specified image and pdf but it won't give photos folder as option although there is pictures in my photo folder. This photo folder I understand is not in the File folder ever on the iphone. – catBuddy Jul 15 '22 at 15:39