Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-19979

iOS: Improvements on the ti.urlsession module

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Low
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: iOS
    • Labels:
    • Environment:

      iOS

    • Sprint:
      2015 Sprint 24 SDK

      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.

      2. Please expose allowsCellularAccess. The default is true. It's useful sometimes to set it false. Thanks.

      Test case:

      • create a default Alloy project. Add URLSession Module. Use the following code:

      index.js

      var urlSession,sessionConfig,session;
       
      function doClick(e) {
          urlSession = require("com.appcelerator.urlSession");
      	sessionConfig = urlSession.createURLSessionBackgroundConfiguration("com.appcelerator.session");
      	session = urlSession.createURLSession(sessionConfig);
      	urlSession.backgroundDownloadTaskWithURL(session, "http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_50mb.mp4");
      	urlSession.backgroundDownloadTaskWithURL(session, "http://www.sample-videos.com/video/mp4/480/big_buck_bunny_480p_50mb.mp4");
      }
       
      function doClick2(e){
      	urlSession.invalidateAndCancel(session);
      }
       
      $.index.open();
       
      Ti.App.iOS.addEventListener('downloadprogress',function(e){
      	Ti.API.info(e.type);
      });
      Ti.App.iOS.addEventListener('downloadcompleted',function(e){
      	Ti.API.info(e.type);
      });
      Ti.App.iOS.addEventListener('sessioncompleted',function(e){
      	Ti.API.info(e.type);
      });
      

      index.xml

      <Alloy>
      	<Window class="container">
      		<Label id="label" onClick="doClick">Click to initiate two tasks</Label>
      		<Label id="label2" onClick="doClick2">Click to cancel two tasks</Label>
      	</Window>
      </Alloy>
      

      index.tss

      ".container": {
      	backgroundColor:"white"
      }
       
      "Label": {
      	width: Ti.UI.SIZE,
      	height: Ti.UI.SIZE,
      	color: "#000"
      }
       
      "#label": {
      	font: {
      		fontSize: 12
      	},
      	top:50
      }
       
      "#label2": {
      	font: {
      		fontSize: 12
      	}
      }
      

      • Click to download two files at the same time, and then click to cancel them all. You can only cancel them all, not individually.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              shawnlan Shawn Lan
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code