Permalink
Browse files

Step 14.15: Use the getPicture method into messages-attachment.ts

  • Loading branch information...
darkbasic committed Jun 7, 2017
1 parent 1980a76 commit a48a16f32ab959ed8785f221fb99a08acb422a29
Showing with 26 additions and 6 deletions.
  1. +26 −6 src/pages/messages/messages-attachments.ts
@@ -17,13 +17,21 @@ export class MessagesAttachmentsComponent {
private pictureService: PictureService
) {}
sendPicture(): void {
this.pictureService.select().then((file: File) => {
this.viewCtrl.dismiss({
messageType: MessageType.PICTURE,
selectedPicture: file
sendPicture(camera: boolean): void {
if (camera && !this.platform.is('cordova')) {
return console.warn('Device must run cordova in order to take pictures');
}
this.pictureService.getPicture(camera, false)
.then((blob: File) => {
this.viewCtrl.dismiss({
messageType: MessageType.PICTURE,
selectedPicture: blob
});
})
.catch((e) => {
this.handleError(e);
});
});
}
sendLocation(): void {
@@ -43,4 +51,16 @@ export class MessagesAttachmentsComponent {
locationModal.present();
}
handleError(e: Error): void {
console.error(e);
const alert = this.alertCtrl.create({
title: 'Oops!',
message: e.message,
buttons: ['OK']
});
alert.present();
}
}

0 comments on commit a48a16f

Please sign in to comment.