{ "id": "150221", "key": "TIMOB-19979", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2015-08-06T18:39:21.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "Community" ], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-02-28T19:56:00.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "1. Right now with URLSession module, you can invalidate the entire session, but cannot cancel a single task. Please add this ability to the module.\r\n\r\n2. Please expose [allowsCellularAccess|https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSURLSessionConfiguration_class/#//apple_ref/occ/instp/NSURLSessionConfiguration/allowsCellularAccess]. The default is true. It's useful sometimes to set it false. Thanks.\r\n\r\nTest case:\r\n\r\n - create a default Alloy project. Add URLSession Module. Use the following code:\r\n\r\nindex.js\r\n{code}\r\nvar urlSession,sessionConfig,session;\r\n\r\nfunction doClick(e) {\r\n urlSession = require(\"com.appcelerator.urlSession\");\r\n\tsessionConfig = urlSession.createURLSessionBackgroundConfiguration(\"com.appcelerator.session\");\r\n\tsession = urlSession.createURLSession(sessionConfig);\r\n\turlSession.backgroundDownloadTaskWithURL(session, \"http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_50mb.mp4\");\r\n\turlSession.backgroundDownloadTaskWithURL(session, \"http://www.sample-videos.com/video/mp4/480/big_buck_bunny_480p_50mb.mp4\");\r\n}\r\n\r\nfunction doClick2(e){\r\n\turlSession.invalidateAndCancel(session);\r\n}\r\n\r\n$.index.open();\r\n\r\nTi.App.iOS.addEventListener('downloadprogress',function(e){\r\n\tTi.API.info(e.type);\r\n});\r\nTi.App.iOS.addEventListener('downloadcompleted',function(e){\r\n\tTi.API.info(e.type);\r\n});\r\nTi.App.iOS.addEventListener('sessioncompleted',function(e){\r\n\tTi.API.info(e.type);\r\n});\r\n{code}\r\n\r\nindex.xml\r\n{code}\r\n\r\n\t\r\n\t\t\r\n\t\t\r\n\t\r\n\r\n{code}\r\n\r\nindex.tss\r\n{code}\r\n\".container\": {\r\n\tbackgroundColor:\"white\"\r\n}\r\n\r\n\"Label\": {\r\n\twidth: Ti.UI.SIZE,\r\n\theight: Ti.UI.SIZE,\r\n\tcolor: \"#000\"\r\n}\r\n\r\n\"#label\": {\r\n\tfont: {\r\n\t\tfontSize: 12\r\n\t},\r\n\ttop:50\r\n}\r\n\r\n\"#label2\": {\r\n\tfont: {\r\n\t\tfontSize: 12\r\n\t}\r\n}\r\n{code}\r\n\r\n- Click to download two files at the same time, and then click to cancel them all. You can only cancel them all, not individually.", "attachment": [], "flagged": false, "summary": "iOS: Improvements on the ti.urlsession module", "creator": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "iOS", "closedSprints": [ { "id": 529, "state": "closed", "name": "2015 Sprint 24 SDK", "startDate": "2015-11-21T01:30:12.670Z", "endDate": "2015-12-05T01:30:00.000Z", "completeDate": "2015-12-07T03:57:17.094Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "359364", "author": { "name": "rtlechuga", "key": "rtlechuga", "displayName": "Radamantis Torres-Lechuga", "active": false, "timeZone": "Asia/Dubai" }, "body": "[~shawnlan] can you please add a test case and more details about this?\r\n\r\nThanks", "updateAuthor": { "name": "rtlechuga", "key": "rtlechuga", "displayName": "Radamantis Torres-Lechuga", "active": false, "timeZone": "Asia/Dubai" }, "created": "2015-08-07T21:53:44.000+0000", "updated": "2015-08-07T21:53:44.000+0000" }, { "id": "359365", "author": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is not a bug. You can use any example here: http://docs.appcelerator.com/platform/latest/#!/guide/iOS_Background_Services\r\n\r\nRight now, to cancel a download, you can use either finishTasksAndInvalidate( session ) or invalidateAndCancel( session ). Both cancel the entire session (all tasks running in that session are cancelled).\r\n\r\nApple's NURLSession actually allows to cancel individual tasks without canceling the whole session. Please expose those methods in TiSDK. Thank you!", "updateAuthor": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-08-07T22:03:08.000+0000", "updated": "2015-08-07T22:04:20.000+0000" }, { "id": "359368", "author": { "name": "rtlechuga", "key": "rtlechuga", "displayName": "Radamantis Torres-Lechuga", "active": false, "timeZone": "Asia/Dubai" }, "body": "[~shawnlan] I know this is not a bug, but still I need to send an example to our engineering team on how the URLSession module works as today and an explanation on how the improvement will help, a use case will be very helpful.\r\n\r\nThanks", "updateAuthor": { "name": "rtlechuga", "key": "rtlechuga", "displayName": "Radamantis Torres-Lechuga", "active": false, "timeZone": "Asia/Dubai" }, "created": "2015-08-07T22:11:41.000+0000", "updated": "2015-08-07T22:11:41.000+0000" }, { "id": "360602", "author": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Okay, test case added. Please see the updated description. Thanks.", "updateAuthor": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-08-21T00:30:55.000+0000", "updated": "2015-08-21T00:30:55.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }