mzeeshanid / MZDownloadManager

This download manager uses NSURLSession api to download files. It can download multiple files at a time. It can download large files if app is in background. It can resume downloads if app was quit.
BSD 3-Clause "New" or "Revised" License
1.12k stars 238 forks source link

Tracking the progress of the Download from downloadingArray #32

Open santanumuvi opened 7 years ago

santanumuvi commented 7 years ago

Hi First of all, thanks for giving such wonderful library. I have started a download in a view controller, then close the view controller, my logic is when

When I come back to that view controller, then I want to show the progress of the downloding (Keeping in mind, I am recreating the view controller)

Now, I am able to get the downloading array from the singleton variable that is downloadManager

so, my code is like this

var arry = self.downloadManager.downloadingArray for index:Int in 0 ..< arry.count { var model = arry[index]

        if let mo = self.movieURL {
        let url = URL(string: self.movieURL)
        if model.fileName! == url?.lastPathComponent{                
            if let button = self.downloadButton{
            // I am trying to get the ongroing progress here however, I am getting 0 here
            }
        }
        }
    }
asiby commented 7 years ago

Wouldn't it be easier to implement MZDownloadManagerDelegate after recreating the view controller? That way, you will receive all the updates from all the active downloads.

DipyaChandniDas commented 7 years ago

@asiby Could you please let me know how to do this?

I am facing the same issue. When click on download, it starts, it can cancel there, if I go back to previous page, and then come back, I am not able to see the download progress as well. If at all I try to cancel the task by getting the task through index, it is not getting started again, its messed up there.

asiby commented 7 years ago

I am simply detaching the delegate when I am moving away from the corresponding viewControllers, then I am re-attaching them when the app navigates back to it.

Also, I would like to add that I have been using this in a NativeScript app. So I doubt that my code will be of any use to you if you are using it in Object C or Swift.

Hopefully this helps.

xtreme8210 commented 6 years ago

hi @asiby Could you please show us how do you attach & detach the delegate? Thank you very much

asiby commented 6 years ago

I will check my code and share it here.

On Wed, Sep 20, 2017 at 5:13 AM, York Lee notifications@github.com wrote:

hi @asiby https://github.com/asiby Could you please show us how do you attach & detach the delegate? Thank you very much

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mzeeshanid/MZDownloadManager/issues/32#issuecomment-330793860, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbz-siF6msg9XV7X9-u51UBv6nuJcYdks5skNcogaJpZM4LmsLF .

shivgolani commented 5 years ago

@asiby I want to integrate MZDownloadManager in my Nativescript App could you please help me with that I'm unable to generate ts typing for this library.

asiby commented 5 years ago

I will try. But it was a very long time ago. I'm try to find the code I wrote back then if I still have it.

On Fri., May 31, 2019, 11:16 shivgolani, notifications@github.com wrote:

@asiby https://github.com/asiby I want to integrate MZDownloadManager in my Nativescript App could you please help me with that I'm unable to generate ts typing for this library.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mzeeshanid/MZDownloadManager/issues/32?email_source=notifications&email_token=AADPH6TCKFQQKJCJXCYD45DPYE6OBA5CNFSM4C42YLC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWVQIKI#issuecomment-497746985, or mute the thread https://github.com/notifications/unsubscribe-auth/AADPH6WLN2S3WKIPU25CYATPYE6OBANCNFSM4C42YLCQ .

shivgolani commented 5 years ago

@asiby Thank you for the response. We are struggling iOS background downloads. If we could integrate this plugin it would be great. Any help would be appreciated.

asiby commented 5 years ago

Hi guys. Bad news. I couldn't find the code I had originally written. And I don't really have any time to rewrite it at this moment. Sorry guys.