phonegap-base64 icon indicating copy to clipboard operation
phonegap-base64 copied to clipboard

Plugin not working in ios

Open rahul-maurya1992 opened this issue 6 years ago • 6 comments

Hi team,

I'm currently using ionic 3 and i implemented this plugin. it's working perfect on android but when i test it on ios there is an issue.

When i try to encode the image in base64 it just quit my page and nothing happens.

Please help me!!!

rahul-maurya1992 avatar Oct 05 '18 04:10 rahul-maurya1992

Had any solution?

rogerbenevento avatar Dec 14 '18 18:12 rogerbenevento

Plugin no response on iOS 12.4.1 @ ionic 3.

sonicwong avatar Oct 16 '19 02:10 sonicwong

BASE 64 not working in IOS device, below code is working for me i used Ionic file plugin

  this.file.readAsDataURL(path, fileName).then(imgURL => {
              alert(imgURL);
              console.log(imgURL + 'test 2') ;
               
            })

I spent many hours on this finally i got the solution for IOS ionic base 64 encoding. follow the below steps.

fileSavedPath: file:///Users/admin/Library/Developer/CoreSimulator/Devices/14915871-D5BD-4631-8618-39714211D8BA/data/Containers/Data/Application/D3EB751F-1989-493B-A166-3481D0B2C88D/Documents/record24920191802.m4a'

 this.filePath = this.file.documentsDirectory + fileSavedPath;
 let fileName =  this.filePath.split('/').pop();
let path =  this.filePath.substring(0,  this.filePath.lastIndexOf("/") + 1);

this.file.readAsDataURL(path,fileName).then((data)=>{
  console.log(data);
  alert(data)
});

For me also not supported used below code.

this.filePath = this.file.documentsDirectory + fileSavedPath; let fileName = this.filePath.split('/').pop(); let path = this.filePath.substring(0, this.filePath.lastIndexOf("/") + 1);

this.file.readAsDataURL(path,fileName).then((data)=>{ console.log(data); alert(data) });

@bluecloudRaj I have been pulling my hair out for a day and a half trying to figure out WHY the base64 from an Android device is being correctly sent, however, with iOS it was somehow being corrupted or not sent correctly. If you use the WebView plugin for Ionic then you can get the Base64 string however, it is not encoded correctly. this is how I accomplished it using the camera plugin

try {
  const fileData: string = await this.camera.getPicture(options);
  const path: string = fileData.substring(0, fileData.lastIndexOf('/') + 1);
  const fileName: string = fileData.split('/').pop();

  const b64: string = await this.file.readAsDataURL(path, fileName);
  const mp4Encoded: string = b64.replace('quicktime', 'mp4');
} catch (err) {
  alert(JSON.stringify(err));
}

note that the above was for a video taken from an iOS that will be able to be seen by Android/iOS

ctfrancia avatar Mar 25 '20 09:03 ctfrancia