LaunchImageLibrary doesn't launch image picker after multiple uses
Description
launchImageLibrary() seems to only return a response 1 time on IOS. It works as it should, opens up the library and then returns a selected image. After the first successful image, trying to launch the library again doesn't work. The response never arrives, image picking library never opens.
How to repeat issue and example
const options = {
mediaType: 'photo',
quality: 0.7,
noData: Platform.OS !== 'ios',
};
console.log(options); // This prints
ImagePicker.launchImageLibrary(options, results => {
console.log(results); // This gets called once, doesn't work afterwards, image library never
opens.
...
}
Additional Information
- React Native version: 0.45.1
- Platform: iOS
- Development Operating System: Mac
- Dev tools: XCode 9.1, IOS 11.1
Same issue here, since I updated to iOS 11
I was also on iOS 11. Wasn't able to solve this issue, but react-native-image-crop-picker seemed to do the trick for me.
I have the same problem also
Current workaround is to use ImagePicker.showImagePicker(...) on iOS in stead of ImagePicker.launchImageLibrary(...).
I'm the same problem
I get the same issue no matter which function I use @ChristiaanHaas
It appears to be an issue with this bit of code:
void (^showPickerViewController)() = ^void() {
dispatch_async(dispatch_get_main_queue(), ^{
UIViewController *root = RCTPresentedViewController();
[root presentViewController:self.picker animated:YES completion:nil];
});
};
RCTPresentedViewController does return a view but calling presentViewController doesn't appear to be doing anything after it's been called once before. Maybe it's something to do with how it's cleaned up after it's closed? Not sure I'm no iOS expert.
react-native-image-crop-picker appears to have the exact same issue. I'm running RN 0.54.0.
Still getting this issue. Anyone found a workaround or something? Only happens in iOS.
any solution ?
This was happening to me when I had an update in the component right after calling launchImageLibrary. When I call it from a button click, it works, but when I call from a modal that is dismissed after calling it, the picker does not open or opens for a second and gets hidden.
I had same problem on iOS (didn't test android yet) for me it work to set the permissions in the Info.plist maually:
open Info.plist under ios/YOUR_PROJECT_NAME and add:
<dict>
...
<key>NSPhotoLibraryUsageDescription</key>
<string>YOUR_REASON_FOR_USING_USER_PHOTOS_HERE</string>
<key>NSCameraUsageDescription</key>
<string>YOUR_REASON_FOR_USING_USER_CAMERA_HERE</string>
</dict>
if you want to allow videos you should also add
NSMicrophoneUsageDescription
on android you can add permissions in the Manifest.xml. You will need the following (as I said didn't test if there is an issue on android)
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
@mateuspiresl was right! The closing modal causes this issue. I have a custom action sheet which is implemented via Modal, and when I call launchImageLibrary and close modal at the same time, library gets opened only for the first time (and callback is getting invoked only once as well). Then I need to restart the app to be able to open gallery one more time. To fix this I have simply delayed launching gallery until modal will get closed, and everything works like a charm!
@sergeylaptev Thanks, just close modal and give a little delay which works on IOS (No such issue on my Android)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.
Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.