Save image/base64/canvas to gallery?

Is there any possible solution to save an image, wheter it is base64 or canvas, in the device gallery? I’m trying to use the Base64 to Gallery Plugin but it just doesn’t work. Here’s my code:

const canvas = document.querySelector('canvas') as HTMLCanvasElement;
const imageData = canvas.toDataURL('image/jpeg').toString();

this.base64ToGallery.base64ToGallery(imageData, {mediaScanner: false, prefix: '_img' }).then(() => {
                this.utils.showOKAlert('Ticket saved', 'Ticket has been successfully saved to gallery');

It shows an error that the data is not correctly encoded. Also, if you google for saving image to devices using ionic framework you’ll have a real hard time to find any clear documentation about it. Has anyone ever needed to save images to gallery using ionic and managed to do it right?