Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
alssl-ross opened this issue Jun 2, 2020 · 62 comments · Fixed by #268
Closed
3 tasks done

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

alssl-ross opened this issue Jun 2, 2020 · 62 comments · Fixed by #268

Comments

@alssl-ross
Copy link

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

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@kokitang

This comment has been minimized.

@jansc

This comment has been minimized.

@fabmesto
Copy link

fabmesto commented Jun 5, 2020

Same error with:
cordova-ios: 6.0.0
cordova-plugin-file-transfer : 1.7.1

@jansc
Copy link

jansc commented Jun 5, 2020

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"];
    }

@kolbasa
Copy link

kolbasa commented Jun 5, 2020

Thank you very much, I'll try that. You can no longer publish an app with cordova-ios v5.1.1.
This issue should be a top priority.
I have only just read that the plugin is deprecated :D.

@fabmesto
Copy link

fabmesto commented Jun 8, 2020

is there any alternative to this plugin?

@kolbasa
Copy link

kolbasa commented Jun 8, 2020

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

@alssl-ross
Copy link
Author

I did go through the process of moving from this plugin to XHR but found that it failed for downloads of large zip files, causing me to revert back to this plugin.

I can compile now thanks to @jansc's comment above. I'm wondering if there is any effect on functionality from removing the userAgent lines. I've not been able to test for myself as yet.

@vtellez
Copy link

vtellez commented Jun 9, 2020

Same error with:
cordova-ios: 6.0.0
cordova-plugin-file-transfer : 1.7.1

I cant not compile with @jansc Solution because Ive got: Plugins/cordova-plugin-inappbrowser/CDVWKInAppBrowser.m:27:9: 'Cordova/CDVUserAgentUtil.h' file not found if I delete Lines 107-110

@kolbasa
Copy link

kolbasa commented Jun 9, 2020

Same error with:
cordova-ios: 6.0.0
cordova-plugin-file-transfer : 1.7.1

I cant not compile with @jansc Solution because Ive got: Plugins/cordova-plugin-inappbrowser/CDVWKInAppBrowser.m:27:9: 'Cordova/CDVUserAgentUtil.h' file not found if I delete Lines 107-110

That was fixed on the master branch of cordova-plugin-inappbrowser:
apache/cordova-plugin-inappbrowser#715

@sohanpc
Copy link

sohanpc commented Jun 11, 2020

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's working for me.
Thank you for saving my time

@alssl-ross
Copy link
Author

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

@MrJohn2014
Copy link

Same issue here. I just comment lane 107-110 and my project could build successfully.

@hefler
Copy link

hefler commented Jun 19, 2020

Although @alssl-ross did a fork removing the lines, I thought about combining @kolbasa 's solution tip into an own fork so that checking still happening: https://github.com/zoopit/cordova-plugin-file-transfer

@sc0ttdav3y
Copy link

Please @alssl-ross create a PR, and hopefully someone with access can merge it in.

alexlopezit added a commit to alexlopezit/cordova-plugin-file-transfer that referenced this issue Jul 7, 2020
dpa99c added a commit to dpa99c/cordova-plugin-file-transfer that referenced this issue Jul 15, 2020
@EinfachHans
Copy link

I switched to use this Fork

@Lyfei
Copy link

Lyfei commented Jul 23, 2020

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"];
    }

After deleting, my network request will not succeed. It seems that userAgent is needed

@timbru31
Copy link
Member

I've created a thread on the dev mailing list to discuss the matter with this plugin. It would help us PMC members to understand the reasons why you rely on the plugin (too) and especially the reasons why you can't migrate to the proposed XHR/fetch alternative.

https://lists.apache.org/thread.html/r4f85264a457ca57301cea226310f920b7f08e5657924a89899ab2b58%40%3Cdev.cordova.apache.org%3E

@HarelM
Copy link

HarelM commented Jul 26, 2020

@timbru31 I have the same issue as @alssl-ross describes.
I have a few lerge files that I need to download from my server and save to the file system - total size of the files is 500Mb. Each file is between 100Mb and 300Mb. I can't split those files into smaller files because they are sqlite database files and splitting them would be a headache.
When I download them using angular/ionic http client the file is loaded into memory before I can store it in the file system using the file-plugin.
In some cases, specifically on iOS, this causes a "white screen of death".
Somewhat related to this issue (see my comment at the end)
apache/cordova-plugin-file#364
When all I want to do is download a file and store it somewhere in the application folders there's a problem in iOS and sometimes it fails when not using this plugin.
I think the problem is related to how much memory is used by the webview, not sure though...

@timbru31
Copy link
Member

@HarelM could you please share this insight with the dev mailing list as requested? I'm pretty sure not all active PMC members and committers are watching this issue.

@rolinger
Copy link

@msudol - why don't you contribute to the project versus criticizing it. I am certain everyone would appreciate the effort.

@msudol
Copy link

msudol commented Mar 18, 2021

@msudol - why don't you contribute to the project versus criticizing it. I am certain everyone would appreciate the effort.

I made no criticism, only a request. Your comment is cringy, unwarranted, and provides even less contribution than mine. Where is your PR speaking of contributing.

@rolinger
Copy link

@msudol - too bad someone can't just develop a plugin that lets us use the same methods as cordova-file-transfer

Doesn't sound like a request....reads like a whiny complaint. Just sayin'. Moving along now...

@timbru31
Copy link
Member

Please be civil :)

I'll remove any other off-topic comments after this one without a warning. Thanks!

@mirko77
Copy link

mirko77 commented Mar 25, 2021

Quick question, on cordova-ios 6.2.0 which by default uses WKWebView, is it only a matter of commenting out those 4 lines of code? Our app uploads video files around 200/300 MB, we are refactoring to WKWebView as per Apple requirements.

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

@regnete
Copy link

regnete commented Mar 26, 2021

@mirko77 I'm using this fork. Works for me. https://github.com/sitewaerts/cordova-plugin-file-transfer.
Diff: master...sitewaerts:master

I created that fork to merge the fixes from https://github.com/zoopit/cordova-plugin-file-transfer plus the current commits of https://github.com/apache/cordova-plugin-file-transfer

@mirko77
Copy link

mirko77 commented Mar 26, 2021

@mirko77 I'm using this fork. Works for me. https://github.com/sitewaerts/cordova-plugin-file-transfer.
Diff: master...sitewaerts:master

I created that fork to merge the fixes from https://github.com/zoopit/cordova-plugin-file-transfer plus the current commits of https://github.com/apache/cordova-plugin-file-transfer

Thanks, very useful, I will give it a try

@markdegrootnl
Copy link

@regnete
Copy link

regnete commented Mar 26, 2021

I'm using https://github.com/dpa99c/cordova-plugin-file-transfer for now

But thats 12 commits behind apache:master.

@Noext
Copy link

Noext commented May 7, 2021

still not working on cordova 10

@mirko77
Copy link

mirko77 commented May 7, 2021

@Noext I do not think this repository ever will, try the linked forks

@aacassandra
Copy link

hub.com/dpa99c/cordova-plugin-file-transfer

thankyou, its works with capacitor 3 and last ionic/vue 2021

@FranGhe
Copy link

FranGhe commented May 27, 2021

Just a question (I have loose some comments) but these plugins
https://github.com/dpa99c/cordova-plugin-file-transfer
https://github.com/sitewaerts/cordova-plugin-file-transfer
work for cordova 10?

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?

@sanderschnydrig
Copy link

To anyone facing this issue this is the only one that worked for me:

(add this to dependencies)

"cordova-plugin-file-transfer": "https://github.com/dpa99c/cordova-plugin-file-transfer/tarball/446b175154491f67bc04a657041a26bc5db92b30",

@regnete
Copy link

regnete commented Jul 14, 2021

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

@rhafiko
Copy link

rhafiko commented Jul 30, 2021

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
Copy link

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

@ng22792
Copy link

ng22792 commented Aug 23, 2021

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

+1

@thesurya9
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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

@vesper8
Copy link

vesper8 commented Mar 11, 2023

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
Copy link

HarelM commented Mar 11, 2023

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...

gallyamow added a commit to gallyamow/cordova-plugin-file-transfer that referenced this issue Apr 18, 2023
@rpcarnell
Copy link

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?

fabiofabbri84 pushed a commit to cimatti/cordova-plugin-file-transfer that referenced this issue Jul 17, 2023
@danicholls
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet