apache / cordova-plugin-file-transfer

Apache Cordova File Transfer Plugin
https://cordova.apache.org/
Apache License 2.0
596 stars 888 forks source link

No known instance method for selector 'userAgent' in CDVFileTransfer.m #258

Closed alssl-ross closed 3 years ago

alssl-ross commented 4 years ago

Bug Report

Problem

When building using cordova-ios v6.0.0 an error is thrown saying:

"No known instance method for selector 'userAgent' in CDVFileTransfer.m"

What is expected to happen?

iOS build and run without error.

What does actually happen?

Error occurs as above

Information

The error occurs on line 107 of CDVFileTransfer.m":

NSString* userAgent = [self.commandDelegate userAgent];

Command or Code

Create a Cordova v9 project using cordova-ios 6.0.0 platform and version 1.7.1 of cordova-plugin-file-transfer run: cordova build ios

Environment, Platform, Device

Build error occurs using Cordova v9. cordova-ios 6.0.0 cordova-file-transfer-plugin v1.7.1

Checklist

rhafiko commented 2 years ago

By removing lines 107-110 from CDVFileTransfer.m I was able to compile:

    NSString* userAgent = [self.commandDelegate userAgent];
    if (userAgent) {
        [req setValue:userAgent forHTTPHeaderField:@"User-Agent"];
    }

it worked for me. Thanks.

muuvmuuv commented 2 years ago

This is again not working. Only the fork worked for me.

ng22792 commented 2 years ago

This is again not working. Only the fork worked for me.

+1

thesurya9 commented 2 years ago

By removing lines 107-110 from CDVFileTransfer.m I was able to compile:

    NSString* userAgent = [self.commandDelegate userAgent];
    if (userAgent) {
        [req setValue:userAgent forHTTPHeaderField:@"User-Agent"];
    }

you are life saver bro.

sushibear commented 2 years ago

Excuse my ignorance, but if they work... why to install them the command is always the same? cordova plugin add cordova-plugin-file-transfer I have to do something else?

cordova plugin add https://github.com/sitewaerts/cordova-plugin-file-transfer

Thanks for the fork, seems to work nicely! :)

byronigoe commented 2 years ago

https://cordova.apache.org/blog/2017/10/18/from-filetransfer-to-xhr2.html

Anyone else notice that the download example in this blog post doesn't actually save the file? You can use cordova-plugin-file to do that like the example here: https://github.com/apache/cordova-plugin-file#write-to-a-file-

kingkarki commented 2 years ago

Given the plugin is deprecated, is it worth creating a pull request? I'm not sure if anyone is able to merge the pull request if it was created.

I've forked this repository and made this change in if it's of use to anyone:

https://github.com/alssl-ross/cordova-plugin-file-transfer

Thank you very much

danielehrhardt commented 2 years ago

npm install https://github.com/apache/cordova-plugin-file-transfer.git

vesper8 commented 1 year ago

To anyone confused (like I was) by the above... it seems that running

cordova plugin add cordova-plugin-file-transfer installs the latest tagged release from 2018

And running cordova plugin add https://github.com/apache/cordova-plugin-file-transfer installs the master version which includes the fix

I guess tagging a new release would be pretty great

HarelM commented 1 year ago

I tried to push that forward but failed, there are falling tests that prevent publishing a new version of this package to npm. If anyone is up for it, it would be great...

rpcarnell commented 1 year ago

I tried jansc 's solution, but when I type ionic capacitor run ios -l --external, the file goes back to what it was. Changes are reverted. Any idea of why this happens?

danicholls commented 1 month ago

NPM seems to have the current version (2.0.0) now. (From 09/2023.)

I don't know if there's any reason to keep using the sitewaerts version (which was a lifesaver!) or anything.