I am coding an App have a feature which save image to gallery in Ionic 4. After research I found base64ToGallery to save img to camera roll with very detail. But it didn't save to camera roll. It save to Library location. There is my code.

let base64Data = this.convertToDataURLviaCanvas(this.listItem[0], 'image/jpeg').then(base64Data => {
      this.base64ToGallery.base64ToGallery(base64Data, { prefix: '_img', mediaScanner: true  }).then(
        res => console.log('Saved image to gallery ', res),
        err => console.log('Error saving image to gallery ', err)

I expect the output show /Media/.... or something to tell me image saved in camera roll. But the actual output is:

2019-05-13 16:17:18.269107+0700 MyApp[3383:933160] Saved image to gallery  /var/mobile/Containers/Data/Application/8214F568-87C5-494C-8CDE-C17C55BBEB83/Library/NoCloud/_img122206160949.png

Base64ToGallery in ionic 4 said:

mediaScanner    boolean 
On Android runs Media Scanner after file creation. On iOS if true the file will be added to camera roll, otherwise will be saved to a library folder.

I'm really appreciates if anyone can help me fix this. I'm using ionic 4, angular 7, ios 12.2.

0 Answers