imagePicker stuck at context.authorize()


#1

imagePicker stuck at context.authorize(), i get the log authorizing… and nothing happens, its redirecting me to the gallery but image picking not working when i tap on the image, gallery window just dissapearing and nothing happens


#2

May I know which device and OS version you are testing it against? Is it the default Gallery app comes in the phone or any third party one?


#3

iphone X emulator, default gallery, plus i tried on iphone 5s real device and on real device gallery is not opening and its not asking me about perrmissions


#4

plugin version is 6.0.1


#5

Did you try a clean build? Does your complied info.plist has the NSPhotoLibraryUsageDescription entry?


#6

yes i tried clean build, there is no NSPhotoLibraryUsageDescription in info.plist


#7

@Giorgius it will be helpful to post your code. Are you using async await ? or .then ? and wait for the promise result ?


#8

@pak437337

viewModel.imgUpTap=(args)=>{
    const context = imagepicker.create({ mode: "single" });

    context.authorize()
    
    .then(()=> {
        return context.present();
    })
    .then((selection)=> {
     
        selection.forEach((selected)=> {
            // process the selected image
            
            selected.getImage().then((source)=>{
     
                viewModel.set("selectedImage",source); 
               
            })               
        });
       
    }).catch((e) =>{
        // process error
    });

}

#9

I have angular project. And with typescript i am not able to get typings for getImage only getImageAsync. Try

let item = selection[0];
item.getImageAsync((image: UIImage, error) => {
});

This is the .d.ts file. As you can see there is no getImage().

export class ImageAsset extends Observable {
    constructor(asset: any);
    getImageAsync(callback: (image: any, error: any) => void); //UIImage for iOS and android.graphics.Bitmap for Android
    ios: any; //PHAsset
    nativeImage: any; //UIImage for iOS and android.graphics.Bitmap for Android
    android: any;
    options: ImageAssetOptions;
}

#10

problem is not getImage(), it stuck at authorizing ,before getImage(), getImage() is not executing.


#11

I think its permissions problem

update: @pak437337 you are right, problem is getImage();

how can I use getImageAsync with vanilla JS?


#12

solved:

selected.getImageAsync((source)=>{
                    viewModel.set("selectedImage",source); 
                });