Cordova / Phonegap:在后台线程中运行FileTransfer插件 [英] Cordova/Phonegap: run FileTransfer plugin in background thread

查看:219
本文介绍了Cordova / Phonegap:在后台线程中运行FileTransfer插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了一个未解决的问题:在后台主题中执行PhoneGap FileTransfer?

I saw an old unsolved question: Run PhoneGap FileTransfer in background thread?

有关此主题的任何消息吗?

Is there any news regarding this topic?

我使用Cordova 3.4.0 with FileTransfer插件并且当我下载一个文件UI UI开始滞后expiant在装载gif一直冻结的iOS设备

I'm using Cordova 3.4.0 with FileTransfer plugin and when i download a file the UI starts to lag expecially on iOS devices where the loading gif is freezed for all the time

是否有平滑下载文件的替代插件?

Is there any alternative plugin for download files smoothly?

推荐答案

我刚刚检查了文件传输的发行说明。此问题已在最新版本中修复:

I just checked the release notes for file-transfer. The issue has been fixed in the latest build:


0.4.3(2014年4月17日)

0.4.3 (Apr 17, 2014)

... CB-5175:[ios] CDVFileTransfer异步下载(修复#24)
...

... CB-5175: [ios] CDVFileTransfer asynchronous download (Fixes #24) ...


$ b b

不幸的是,这个构建完全打破了文件传输下载,不调用success或fail回调。请参阅 https://issues.apache.org/jira/browse/CB-6720?focusedCommentId=14008776&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14008776

我手动修补了CDVFileTransfer.m以包含最新版本的后台线程代码。在下载方法中,您需要替换

I manually patched CDVFileTransfer.m to include the background thread code from the latest version. In the download method you need to replace

[delegate.connection start];

// Downloads can take time
// sending this to a new thread calling the download_async method
dispatch_async(
               dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL),
               ^(void) { [delegate.connection start];}

对我来说,但显然你是自己的,直到科尔多瓦发布正式的解决方案。

So far this has been working reliably for me, but obviously you're on your own until Cordova releases an official fix.

这篇关于Cordova / Phonegap:在后台线程中运行FileTransfer插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆