{"action":"created","issue":{"url":"https://api.github.com/repos/Alamofire/Alamofire/issues/1052","repository_url":"https://api.github.com/repos/Alamofire/Alamofire","labels_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/1052/labels{/name}","comments_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/1052/comments","events_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/1052/events","html_url":"https://github.com/Alamofire/Alamofire/issues/1052","id":131880685,"number":1052,"title":"Reconnecting to In Progress Background Transfers","user":{"login":"ronak2121","id":1755751,"avatar_url":"https://avatars.githubusercontent.com/u/1755751?v=3","gravatar_id":"","url":"https://api.github.com/users/ronak2121","html_url":"https://github.com/ronak2121","followers_url":"https://api.github.com/users/ronak2121/followers","following_url":"https://api.github.com/users/ronak2121/following{/other_user}","gists_url":"https://api.github.com/users/ronak2121/gists{/gist_id}","starred_url":"https://api.github.com/users/ronak2121/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronak2121/subscriptions","organizations_url":"https://api.github.com/users/ronak2121/orgs","repos_url":"https://api.github.com/users/ronak2121/repos","events_url":"https://api.github.com/users/ronak2121/events{/privacy}","received_events_url":"https://api.github.com/users/ronak2121/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Alamofire/Alamofire/labels/question","name":"question","color":"FF7E00"},{"url":"https://api.github.com/repos/Alamofire/Alamofire/labels/url%20session","name":"url session","color":"69B805"}],"state":"closed","locked":false,"assignee":{"login":"cnoon","id":169110,"avatar_url":"https://avatars.githubusercontent.com/u/169110?v=3","gravatar_id":"","url":"https://api.github.com/users/cnoon","html_url":"https://github.com/cnoon","followers_url":"https://api.github.com/users/cnoon/followers","following_url":"https://api.github.com/users/cnoon/following{/other_user}","gists_url":"https://api.github.com/users/cnoon/gists{/gist_id}","starred_url":"https://api.github.com/users/cnoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cnoon/subscriptions","organizations_url":"https://api.github.com/users/cnoon/orgs","repos_url":"https://api.github.com/users/cnoon/repos","events_url":"https://api.github.com/users/cnoon/events{/privacy}","received_events_url":"https://api.github.com/users/cnoon/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2016-02-06T17:53:03Z","updated_at":"2016-02-09T14:08:30Z","closed_at":"2016-02-06T19:36:00Z","body":"Hi,\r\n\r\nI have a question regarding how Alamofire works with in progress background transfers.\r\n\r\nSo, imagine this scenario:\r\n\r\n1. User opens up your app\r\n2. User queues up a collection of background transfers\r\n3. User backgrounds your app\r\n4. User launches other apps enough to force the system to terminate your app\r\n5. User relaunches your app while at least one of your previous background transfers were running.\r\n\r\nSome questions here:\r\n\r\n1. Is this a realistic edge case?\r\n2. It looks like the existing Alamofire SessionDelegate multiplexes the delegate callbacks based on taskIdentifiers instead of by URL, which means that client code would have to recreate the tasks that were running apriori in order to match up by taskIdentifier again. (Seems like a very hacky, buggy solution).\r\n3. Apps would have to check at app launch to see if there are any background transfers that are running, and override Alamofire's SessionDelegate using the blocks.\r\n\r\nThe question I have with number 3 is if we should be removing the override once all background transfers have completed? What happens if the user starts new ones? In this scenario, it seems like I would be working around Alamofire's code a lot...\r\n\r\nThanks,\r\n\r\nRonak"},"comment":{"url":"https://api.github.com/repos/Alamofire/Alamofire/issues/comments/181878081","html_url":"https://github.com/Alamofire/Alamofire/issues/1052#issuecomment-181878081","issue_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/1052","id":181878081,"user":{"login":"ronak2121","id":1755751,"avatar_url":"https://avatars.githubusercontent.com/u/1755751?v=3","gravatar_id":"","url":"https://api.github.com/users/ronak2121","html_url":"https://github.com/ronak2121","followers_url":"https://api.github.com/users/ronak2121/followers","following_url":"https://api.github.com/users/ronak2121/following{/other_user}","gists_url":"https://api.github.com/users/ronak2121/gists{/gist_id}","starred_url":"https://api.github.com/users/ronak2121/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronak2121/subscriptions","organizations_url":"https://api.github.com/users/ronak2121/orgs","repos_url":"https://api.github.com/users/ronak2121/repos","events_url":"https://api.github.com/users/ronak2121/events{/privacy}","received_events_url":"https://api.github.com/users/ronak2121/received_events","type":"User","site_admin":false},"created_at":"2016-02-09T14:08:30Z","updated_at":"2016-02-09T14:08:30Z","body":"What I mean by multiplexing is that you currently have a dictionary in the SessionDelegate where you map from NSURLSessionTask to Request using the task identifier.\n\nThat wouldn't hold up across app restarts since we lose the mapping from a Request Object to its task identifier. It would be better to use the url in that dictionary since the app would know which downloads are still in progress (assuming the app is keeping track in a persistence store of some kind) and can easily recreate the Request objects.\n\nTe second point I was making was there is a slight threading concern with the way the request closures work in that they are dispatched to the set table queue.\n\nThe main points I am trying to make here are that I don't think you would have to re-engineer your code so much and tear it all up for this.\n\nSent from my iPhone\n\n> On Feb 9, 2016, at 12:31 AM, Christian Noon <notifications@github.com> wrote:\n> \n> I don't understand your reasoning here @ronak2121. First off, I don't understand what you mean by multiplexing in #1. As for #2, I don't understand what that accomplishes. Additionally, recreating requests is only easy if you have them completely abstracted and all callbacks are done using a delegate pattern, not closures.\n> \n> ―\n> Reply to this email directly or view it on GitHub.\n> \n"}}