Hello,
I’m creating a chat app at the moment, similar to for example whats app and now I got problems with saving the Images on android with the error message: “Error while saving image”. On iOS all works without any problems.
I’m getting the Image from the Server as a base64 string.
I thought it maybe has to do something with the permissions but I checked them with @ionic-native/androidPermissions and this @ionic-nativ/diagnostics and both plugins told me that I got the required permissions.
The Code of the Saving Image function:
savePhoto(base64String){
this.base64ToGallery.base64ToGallery(base64String, {prefix: '_img', mediaScanner: true}).then(
res => {
console.log("Saved image to gallery:", res)
//more code on this point, but shouldn't affect the base64 plugin
},
err => console.log('Error saving image to gallery:', err)
)
Code of grantPermission with androidPermissions:
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE).then(
result => console.log("Has Permission?", result.hasPermission),
err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE)
)
Code with ionic diagnostics:
getStatusPermissionDiagnostics(){
let successCallback = (isAvailable) => { console.log('Is available? ' + isAvailable); }
let errorCallback = (e) => console.error(e);
this.diagnostic.getExternalStorageAuthorizationStatus().then(
successCallback).catch(errorCallback)
}
grantPermissionDiagnostics(){
let successCallback = (isAvailable) => { console.log('Is available? ' + isAvailable); }
let errorCallback = (e) => console.error(e);
this.diagnostic.requestRuntimePermission(this.diagnostic.permission.WRITE_EXTERNAL_STORAGE).then(successCallback).catch(errorCallback)
}