ImagePicker launchImageLibraryAsync not working on Expo Go

Please provide the following:

  1. SDK Version: 47.0.0
  2. Platforms(Android/iOS/web/all): iOs
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

Hello, I have been trying to convert an image picked from an ios device into base64 and send the data to an API using the launchImageLibraryAsync function.
I got the ImagePickerResult object using the web simulator on Expo Go (Chromium Edge) in both the 46.0.0 and the 47.0.0 versions.
However, when I tried to run the app on my iPhone I could only get the ImagePickerResult object in v. 46.0.0 which after multiple tries doesn’t convert the image into base64 when the base64 option is true. Therefore, I changed to v. 47.0.0 which shows an empty object and a bunch of warnings as seen in the image attached.

Can you please provide any explanation and help me?
Sincerely.

Hello,
I realized after trying multiple times to solve error shown in the console log, I tried to see the base64 value anyway by just printing it out in setText(result.base64) and by surprise, it works.
For some reason, there’s still an “Unhandled promise rejection Error” thrown as you can see even after wrapping everything in a try-catch.
I hope this issue will be addressed in the future.

Hi @aliou0

Your code seems to work for me, still with a couple of warnings, but no unhandled promise rejection:

Hello,
Yes, as mentioned in my second post I figured out that I was able to get the base64 data from result.data . I also realized that the code wouldn’t throw any error when I use the ios simulator to console.log the base64 value, but does when I use a real device.
For example, in the images below, I only tried to console.log the base64 value of an image after it was taken by the camera. As you can see the log is still showing the " Unhandled promise rejection Error: “PubNub call failed, check status for details” " when a real device is used.
I also believe whenever we add the base64 option in a function from any expo API we face the same issue (with real devices).
Hopefully, this will be fixed.


Hello,
I finally found out the reason I’d get this warning wasn’t the base64 conversion with expo APIs but rather the display of the base64 string in the console. It was just too long, exceeding the number of characters displayable (10000 I think).
As shown in the screenshot below, I tested it by limiting the number of characters to 3000 (using console.log(image.substring(0, 3000)).

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.