Here’s my test. I connected an android device in my PC. Then ran ionic cordova run android
. It load the app in the android device. I was able to test the upload image and it works fine. I deploy/publish code to Ionic View (pro). I opened the Ionic View app in my Iphone device. Tested the app but nothing happens when I click (which should navigate to images/download folder.
editimage() {
let statusalert = this.alertCtrl.create({
buttons: ['okay']
});
this.imgSvc.uploadimage().then((url: any) => {
this.userservice.updateimage(url).then((res: any) => {
if (res.success) {
statusalert.setTitle('Updated');
statusalert.setSubTitle('Your profile pic has been changed successfully!!');
statusalert.present();
this.zone.run(() => {
this.avatar = url;
})
}
}).catch((err) => {
statusalert.setTitle('Failed');
statusalert.setSubTitle('Your profile pic was not changed');
statusalert.present();
})
})
}
And the imgSvc.uploadimage()
is this:
uploadimage() {
var promise = new Promise((resolve, reject) => {
this.filechooser.open().then((url) => {
(<any>window).FilePath.resolveNativePath(url, (result) => {
this.nativepath = result;
(<any>window).resolveLocalFileSystemURL(this.nativepath, (res) => {
res.file((resFile) => {
var reader = new FileReader();
reader.readAsArrayBuffer(resFile);
reader.onloadend = (evt: any) => {
var imgBlob = new Blob([evt.target.result], { type: 'image/jpeg' });
var imageStore = this.firestore.ref('/profileimages').child(firebase.auth().currentUser.uid);
imageStore.put(imgBlob).then((res) => {
this.firestore.ref('/profileimages').child(firebase.auth().currentUser.uid).getDownloadURL().then((url) => {
resolve(url);
}).catch((err) => {
reject(err);
})
}).catch((err) => {
reject(err);
})
}
})
})
})
})
})
return promise;
}