1

I'm trying to perform a GET request to download a PDF document to the phone. The responseType is blob as I need the result as a Blob file.

import {
  HttpClient
} from '@angular/common/http';

this.httpClient
   .get(specSheet.link, {
     responseType: 'blob'
   })
   .subscribe(result => {

     console.log('http client download result: ', result)

Everything works as expected on web and ran in Chrome. http client download result: Blob {size: 174016, type: "application/pdf"}

But on iOS or Android the result is empty http client download result: {}.

What am I missing? Any help is greatly appreciated.

PS: Here's a simple playground just downloading a test image: https://github.com/davidseek/ionic-playground

It works perfectly fine ran on web. But not at all on a physical device. Web result is a Blob, phone result is empty: {}

David Seek
  • 16,783
  • 19
  • 105
  • 136

1 Answers1

2

That's just the console plugin not being able to display complex objects on the Xcode console.

If you debug the app using Safari remote inspector you'll see the actual blob. blob

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • Unbelievable. Yeah you helped me tremendously... Thank you! Since I got you here right now, do you have a little tip for me how I can deploy changes as fast as it gets from Visual Code -> Xcode -> iPhone? Right now I do: `ng build` -> `npx cap copy` -> switch to Xcode -> build. Is there like a faster way? Even with my iMac Pro this seems like a huge time waste. – David Seek Sep 20 '19 at 20:37
  • you can use live reload, see https://stackoverflow.com/questions/53328647/ionic4-capacitor-android-livereload/53338145#53338145 – jcesarmobile Sep 20 '19 at 21:42