Quantcast
Viewing all articles
Browse latest Browse all 8068

URLSession - sessioneventscompleted

someone's example code

My question is about the above app.js. Line 98-106

if(isBGTransferMode) {
        var pendingDL = Ti.App.Properties.getObject('pendingDL');
        if (pendingDL == null){
            pendingDL = [];
        }
        if (pendingDL.length == 0) {
             Ti.App.iOS.endBackgroundHandler(bgHandlerID);
        }
    }
Why does it check if there is any pending download? Isn't it redundant? My understanding is that sessioneventscompleted fired when all downloads are either finished or failed. There shouldn't be any pending download, right? Do I miss anything?

Even if there are still pending downloads, I should still call Ti.App.iOS.endBackgroundHandler(bgHandlerID), to let my app go to suspended. The pending downloads can run on themselves anyway.

So if I'm correct, all the if's here are redundant. I should call Ti.App.iOS.endBackgroundHandler(bgHandlerID) no matter what. This piece of code is confusing. Can anyone confirm or point out what I miss?

Thanks.


Viewing all articles
Browse latest Browse all 8068

Trending Articles