Problem Downloading Insecure Images On iOS

I ran into a problem downloading insecure http:// images on iOS using the HTTP plugin. The downloadFile request fails with the error There was an error downloading the file.

I suspect it’s related to iOS restrictions on insecure content, so think setting setSSLCertMode to nocheck would help.

However whenever I try calling setSSLCertMode I get the warning Ionic Native: tried calling HTTP.setSSLCertMode, but the HTTP plugin is not installed in the console.

Ionic Native: tried calling HTTP.setSSLCertMode, but the HTTP plugin is not installed.
Install the HTTP plugin: 'ionic cordova plugin add cordova-plugin-advanced-http'

The plugin is installed though, since I can remove the setSSLCertMode call and HTTP requests work fine.

Unfortunately some of our images are hosted on Rackspace on http:// and haven’t been migrated to https://, so I’m stuck trying to load these insecure images.

Any thoughts or suggestions?

Since I’m not having much luck with HTTP plugin, I tried FileTransfer plugin instead however for any http:// images the download promise never returns or even throws an error.

let url = "http://3775e5d250868dab9385-0b4c691ea14dad11384ab079da46af4f.r79.cf2.rackcdn.com/dale.api.ushahidi.io/5/8/583c9af333b52-usa_canada.jpg";
let file = this.file.cacheDirectory + "image.jpg";
let fileTransfer:FileTransferObject = this.transfer.create();
fileTransfer.download(url, file, true).then((entry:any) => {
  console.log(entry.toURL());
},
(error:any) => {
  console.error(error);
});

Hmm, what’s kind of baffling is this use to work fine previously. So either it’s being caused by tighter iOS security restrictions or there’s a problem in the latest native plugins.

Ok, think I tracked down the issue, just posting in case someone runs into the same problem.

Looks like the config.xml had some changes to the access tags to increase security in the app. However the unintended side effect must have been blocking access to those http:// images on Rackspace.

If I removed all the access tags and just add the following, then the images download and load fine in the app.

<access allows-arbitrary-loads-for-media="true" allows-arbitrary-loads-in-web-content="true" allows-local-networking="true" origin="*" />

More information about access tags here https://cordova.apache.org/docs/en/8.x/reference/cordova-plugin-whitelist/#network-request-whitelist