-
-
Notifications
You must be signed in to change notification settings - Fork 18
"Progress" && "Completed" callback never comes but finishes downloading the file and i can see in the storage #34
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
Comments
I'm having this same issue on iOS emulator. When I call I don't get any progress updates from the progress callback and the promise is not resolved or rejected. Everything seems to work fine on the Android emulator. |
hello @triniwiz do you have any update on this bug or any plan to get it fixed? |
Debugging i found that the task.state (the task is a |
For those who have an urge for this you must at least create a fork for this project and go to downloader.ios.ts and comment all lines and codes like this: line 86: if (task && task.state === NSURLSessionTaskState.Running) { from line 133 to 143: } else if (task.state === NSURLSessionTaskState.Suspended) {
const data = owner.downloadsData.get(id);
if (data) {
owner.downloadsData.set(
id,
Object.assign({}, data, {
status: StatusCode.PAUSED
})
);
}
} and finally line 164: task.state === NSURLSessionTaskState.Completed && With this you can have progress and completion handlers being called but maybe the status PAUSE will not work. |
I cloned the repo and tried to replicate the issue with the demo app. I updated the demo app to download the same file as my Angular NS app and it works fine. I tried updating the info.plist to match my app and it still works fine. I cannot replicate with the demo app, for some reason. |
When using the plugin with my Angular NS app, as @darkyelox stated, |
@triniwiz I have this problem too. Is there going to be a fix for this? |
@tomfaltesek @triniwiz I found out that this plugin does not work with Nativescript 5.3.0+. Latest version of the Nativescript that works with this plugin is 5.2.2. You can test it by downgrading NS version:
|
I made a temporary fix but you have to edit a file in node_modules folder. Open if(progress.finished) {
task.state = 3;
}
else if(progress.paused) {
task.state = 1;
}
else {
task.state = 0;
} The related part of the file will look like this: var task = download.downloadTaskWithRequestProgressDestinationCompletionHandler(request, function (progress) {
if(progress.finished) {
task.state = 3;
}
else if(progress.paused) {
task.state = 1;
}
else {
task.state = 0;
}
dispatch_async(main_queue, function () { I hope this helps anybody who faces this problem until this library is updated. |
Thanks @erkanarslan for the workaround. But sadly this throws an error all the time:
I also tweaked a bit around this code lines but with no success :( |
I had this problem too. But when I reinstalled the package and applied my changes it worked. Try reinstalling it. |
Just submitted a PR (#35) that fixes the task state issues with iOS in NS 5.4.0+. The download speed doesn't work, but at least the plugin is usable. |
@triniwiz @acharyaks90 @matecode Will we get a new release with the fixes from @tomfaltesek PR #35 ? |
@triniwiz Please release |
@triniwiz push ⇪ |
please release, great work everyone |
FYI to those watching this issue -- I tried switching to this plugin, for now: https://github.com/tobydeh/nativescript-download-progress It works with the latest NS 5.4.0+ on both platforms. |
@triniwiz It would be great if you could please release a new version of your plugin to get it working again with NS >= 5.4.0. |
So this bug is related to NativeScript/ios-jsc#1149 an using the fix here should will help NativeScript/ios-jsc#1149 (comment) |
@triniwiz Thank you very much for your hint to the bug inside the iOS-runtime! Hopefully it will be fixed there soon. |
Still having this issue. Is there any workaround for android? |
Android is also having the same issue :( |
Same issue on Android |
Did some debugging, looks like
However, download seems to work the first time after app is launched. |
it looks like the value in |
"Progress" && "Completed" callback never comes but finishes downloading the file but i can see in the storage!!!
Please help i am Using nativescript with angular and i have a scene where 2 lazy loaded module both shares a component of another common module which have the downloader service...i have initiated the Downloader.init(); in the common module component.
My aim was to download from those 2 parent module using same downloader service using in that common module. Now it works fantastic when i downloads file as much as i request from the same module it works fine...but whenever i go to the 2nd module and try to download from there using the same common module it started but it never gives the callback in return like "Progress" status & "Completed" status...no error..it just got stuck but the interesting thing is that when i check the storage it actually downloads that file as expected only the callbacks get stops when i use same service from different module. And my process entirely depends on the complete status
If the demo apps cannot help and there is no issue for your problem, tell us about it
Please, ensure your title is less than 63 characters long and starts with a capital
letter.
Which platform(s) does your issue occur on?
Please, provide the following version numbers that your issue occurs with:
"dependencies": {
"@angular/common": "~6.1.0",
"@angular/compiler": "~6.1.0",
"@angular/core": "~6.1.0",
"@angular/forms": "~6.1.0",
"@angular/http": "~6.1.0",
"@angular/platform-browser": "~6.1.0",
"@angular/platform-browser-dynamic": "~6.1.0",
"@angular/router": "~6.1.0",
"@auth0/angular-jwt": "^2.1.0",
"@nota/nativescript-webview-ext": "^5.0.0-alpha.2",
"email-validator": "^1.0.7",
"lodash": "^4.17.11",
"lodash.filter": "^4.6.0",
"nativescript-accordion": "^6.0.0-beta.2",
"nativescript-angular": "~6.1.0",
"nativescript-audio": "^5.0.1",
"nativescript-audio-ssi": "^4.0.6",
"nativescript-background-http": "^3.4.0",
"nativescript-camera": "^4.1.1",
"nativescript-cardview": "^3.1.1",
"nativescript-download-progress": "^1.1.0",
"nativescript-downloader": "^2.1.4",
"nativescript-downloadmanager": "^0.1.0",
"nativescript-drop-down": "^4.0.1",
"nativescript-feedback": "^1.3.1",
"nativescript-imagepicker": "^6.0.6",
"nativescript-iqkeyboardmanager": "~1.2.0",
"nativescript-loading-indicator": "^2.4.0",
"nativescript-localize": "^3.0.6",
"nativescript-localstorage": "^2.0.0",
"nativescript-modal-datetimepicker": "^1.1.10",
"nativescript-nativemediapicker": "^1.0.1",
"nativescript-ngx-fonticon": "^4.2.0",
"nativescript-pdf-view": "^2.0.1",
"nativescript-photo-editor": "^1.0.3",
"nativescript-plugin-firebase": "^7.6.1",
"nativescript-popup": "^1.5.0",
"nativescript-segment-view": "^1.0.6",
"nativescript-snackbar": "^4.1.0",
"nativescript-social-share": "~1.4.0",
"nativescript-status-bar": "^1.1.1",
"nativescript-svg": "^1.3.4",
"nativescript-theme-core": "^1.0.4",
"nativescript-ui-listview": "^5.0.1",
"nativescript-ui-sidedrawer": "^4.3.1",
"nativescript-unit-test-runner": "^0.3.3",
"nativescript-zip": "^3.0.0",
"reflect-metadata": "^0.1.12",
"rxjs": "~6.1.0",
"tns-core-modules": "~5.0.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/compiler-cli": "~6.1.0",
"@ngtools/webpack": "~6.2.0",
"@types/chai": "^4.0.2",
"@types/lodash": "^4.14.118",
"@types/mocha": "^2.2.41",
"@types/node": "^7.0.5",
"@nativescript/schematics": "~0.3.0",
"babel-traverse": "6.24.1",
"babel-types": "6.24.1",
"babylon": "6.17.0",
"codelyzer": "^3.0.1",
"filewalker": "^0.1.3",
"jasmine-core": "^2.6.2",
"karma": "^1.7.0",
"karma-jasmine": "^1.0.2",
"karma-nativescript-launcher": "^0.4.0",
"lazy": "1.0.11",
"nativescript-css-loader": "~0.26.0",
"nativescript-dev-android-snapshot": "0.0.11",
"nativescript-dev-appium": "~4.0.6",
"nativescript-dev-typescript": "^0.7.4",
"nativescript-dev-webpack": "^0.16.3",
"tslint": "^5.4.2",
"typescript": "~2.7.2"
}
The text was updated successfully, but these errors were encountered: