File Transfer Plugin adds "X-Requested-With: XMLHttpRequest" Header ONLY on iOS

Hi, I’m writing an app that uploads pictures to my ownCloud server with the File Transfer Plugin which internally uses a PUT request. Here is the relevant part of my code:

import {Transfer} from "ionic-native";
...
upload(imgToUpload) {
  let transfer = new Transfer();
  let URL: "https://username:password@owncloud.../remote.php/webdav/folder/"
  let options = {
    httpMethod: "PUT"
  }

  transfer.upload(imgToUpload, URL, options, true).then(
    (succ) => {},
    (err) => {console.log(err.http_status+" "+err.body);}
  );
}

The whole thing works on Android, but on iOS get the following error from ownCloud:

401 <?xml version="1.0" encoding="utf-8"?> 
  <d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
    <s:exception>Sabre\DAV\Exception\NotAuthenticated</s:exception>
    <s:message>Cannot authenticate over ajax calls</s:message>
  </d:error>

It seems that the error originates here in the ownCloud source code. Apparently the File Transfer Plugin adds the X-Requested-With: XMLHttpRequest header, but I don’t understand why this only happens on iOS and not on Android.

Does anyone know how to fix this?
Thanks in advance!

The platform implementations of https://github.com/apache/cordova-plugin-file-transfer obviously are different. Did you look at the Android calls to see if the header was present there?

You could fork the cordova-plugin-file-transfer and remove this line: https://github.com/apache/cordova-plugin-file-transfer/blob/5a711e8722804d4d427fa5e580c9e6767c8a6cee/src/ios/CDVFileTransfer.m#L105 This would probably help, but maybe cause all kinds of other problems.