Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19154] iOS9: Replace NSURLConnection in Ti.Network.HTTPClient with NSURLSession

GitHub Issuen/a
TypeImprovement
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-02-22T21:09:33.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.1.0
ComponentsiOS
Labelshttpclient
ReporterChee Kiat Ng
AssigneeVijay Singh
Created2015-07-03T03:13:33.000+0000
Updated2018-02-23T16:21:22.000+0000

Description

NSURLConnection methods have been deprecated in iOS9 in favor of NSURLSession.

WWDC 2015 reference

https://developer.apple.com/videos/wwdc/2015/?id=711

NSURLConnection reference

https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/index.html#//apple_ref/doc/uid/TP40003755

NSURLSession reference

https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSURLSession_class/index.html#//apple_ref/doc/uid/TP40013435

Affected Titanium Class

https://github.com/appcelerator/APSHTTPClient

Attachments

FileDateSize
appcelerator.https-iphone-2.3.0.zip2018-02-01T01:24:24.000+00002978522
Screen Shot 2015-07-03 at 11.19.15 am.png2015-07-03T03:39:16.000+000089745
Screen Shot 2015-07-03 at 11.22.50 am.png2015-07-03T03:39:16.000+000050639

Comments

  1. Chee Kiat Ng 2015-07-07

    Master PR: https://github.com/appcelerator/titanium_mobile/pull/7030 APSHTTPClient PR: https://github.com/appcelerator/APSHTTPClient/pull/26

    Steps to Test

    1. Include this in in ios plist in tiapp.xml in KitchenSink
                       <key>NSAppTransportSecurity</key>
                       <dict>
                           <key>NSAllowsArbitraryLoads</key>
                           <true/>
                       </dict>
       
    2. Run KitchenSink 3. Go to *platform->XHR* 4. Test every functionality there, except the following: - Cookies since the url is outdated. - FileDownload -> Large File Download. URL here is outdated too. It's possible to replace this one to test further. Use http://ipv4.download.thinkbroadband.com/200MB.zip

    Expected Result

    Everything should work.
  2. Chee Kiat Ng 2015-07-09

    *Note*: There should be a blog post and documentation ticket to inform titanium devs about the requirement to set NSAppTransportSecurity key in tiapp.xml.
  3. Chee Kiat Ng 2015-08-16

    PRs merged.
  4. Chee Kiat Ng 2015-08-27

    Reopening because PRs were implemented wrongly. New PR here to revert the changes to ensure everything still works for Release 5.0.0. https://github.com/appcelerator/APSHTTPClient/pull/30 https://github.com/appcelerator/titanium_mobile/pull/7078 And pushing this to Release 5.1.0.
  5. Chee Kiat Ng 2015-09-04

  6. Chee Kiat Ng 2015-09-08

    APSHTTPClient PR:https://github.com/appcelerator/APSHTTPClient/pull/31 Master PR: https://github.com/appcelerator/titanium_mobile/pull/7137 5_0_X PR: https://github.com/appcelerator/titanium_mobile/pull/7138 MERGE AFTER 5.0.0.GA is released.
  7. Hans Knöchel 2015-09-27

    PR's reviewed, tested & approved. Thank you Kiat!
  8. Eric Wieber 2015-10-29

    Verified fixed, using: MacOS 10.11.2 (15C27e) Studio 4.4.0.201510280736 Ti SDK 5.1.0.v20151028190028 Appc NPM 4.2.1 Appc CLI 5.1.0-38 Ti CLI 5.0.5 Alloy 1.7.16 Arrow 1.3.13 Xcode 7.2 (7C46l) Node v0.12.7 Java 1.7.0_80 production Ran the sample code and each of the tests/outputs passed or matched the expected for an iOS 9.2 device.
  9. Chee Kiat Ng 2016-01-14

  10. tom quas 2016-07-07

    six months later and still critical ... more than ever. any plans to finish this one soon? sidenote: this ticket blocks us today from testing secure http/2 connections using the standard sdk; and apple's deadline is coming closer...
  11. Hans Knöchel 2016-07-24

    [~tom] We do understand your concerns and the priority of this ticket, but we also have to schedule it properly to match the current roadmap and tickets that are included in it. The current roadmap for this ticket is *Release 7.0.0*, but we will keep this ticket up-to-date if there is an earlier release possible. Thanks!
  12. Vijay Singh 2017-08-29

    APSHTTPClient PR - https://github.com/appcelerator/APSHTTPClient/pull/40 appcelerator.https PR - https://github.com/appcelerator-modules/appcelerator.https/pull/46 Master PR - https://github.com/appcelerator/titanium_mobile/pull/9366 7_1_X PR - https://github.com/appcelerator/titanium_mobile/pull/9854
  13. Vijay Singh 2017-12-27

  14. Hans Knöchel 2018-01-02

    28 test-cases: https://gist.github.com/hansemannn/5021f0aaf2bcbe5ed054449912f3b92b Two additional ones (stress-tests in successively and concurrent): *Successively*
        var NUMBER_OF_TESTS = 30;
        
        var btn = Ti.UI.createButton({
          title: 'Trigger'
        });
         
        var win = Ti.UI.createWindow({
          backgroundColor: '#fff',
          rightNavButton: btn
        });
          
        var nav = Ti.UI.iOS.createNavigationWindow({
          window: win
        });
        
        var list = Ti.UI.createListView();
        
        win.add(list);
        btn.addEventListener('click', runStressTest);
        nav.open();
         
        function runStressTest() {
          var cells = [];
          
          for (var i = 1; i <= NUMBER_OF_TESTS; i++) {
            cells.push({
              properties: {
                title: 'Test ' + i + ' (running)'
              }
            });
          }
          
          list.setSections([Ti.UI.createListSection({ items: cells })]);
          runTest(1);
        }
        
        function runTest(num) {
          function check(success) {
            var label = success ? 'done' : 'failed';
            var item = list.sections[0].getItemAt(num - 1);
        
            item.properties.title = 'Test ' + num + ' (' + label + ')';
            item.properties.backgroundColor = success ? 'green' : 'red';
            
            if (success) {
              item.properties.accessoryType = Titanium.UI.LIST_ACCESSORY_TYPE_CHECKMARK;
            } else {
              item.properties.accessoryType = Titanium.UI.LIST_ACCESSORY_TYPE_NONE;
            }
            list.sections[0].updateItemAt(num - 1, item);
            
            if (num < NUMBER_OF_TESTS) {
              runTest(num + 1);
            } else {
              alert('ALL DONE!');
            }
          }
          
          var url = "http://www.appcelerator.com";
          var client = Ti.Network.createHTTPClient({
            onload : function(e) {
                check(true);
            },
            onerror : function(e) {
                check(false)
            },
            timeout : 30000  // 30sec
          });
        
          client.open("GET", url);
          client.send();
        }
        
    *Concurrent*
        var NUMBER_OF_TESTS = 30;
        
        var btn = Ti.UI.createButton({
          title: 'Trigger'
        });
         
        var win = Ti.UI.createWindow({
          backgroundColor: '#fff',
          rightNavButton: btn
        });
          
        var nav = Ti.UI.iOS.createNavigationWindow({
          window: win
        });
        
        var list = Ti.UI.createListView();
        
        win.add(list);
        btn.addEventListener('click', runStressTest);
        nav.open();
         
        function runStressTest() {
          var cells = [];
          
          for (var i = 1; i <= NUMBER_OF_TESTS; i++) {
            runTest(i);
            cells.push({
              properties: {
                title: 'Test ' + i + ' (running)'
              }
            });
          }
          
          list.setSections([Ti.UI.createListSection({ items: cells })]);
        }
        
        function runTest(num) {
          function check(success) {
            var label = success ? 'done' : 'failed';
            var item = list.sections[0].getItemAt(num - 1);
        
            item.properties.title = 'Test ' + num + ' (' + label + ')';
            item.properties.backgroundColor = success ? 'green' : 'red';
            
            if (success) {
              item.properties.accessoryType = Titanium.UI.LIST_ACCESSORY_TYPE_CHECKMARK;
            } else {
              item.properties.accessoryType = Titanium.UI.LIST_ACCESSORY_TYPE_NONE;
            }
            list.sections[0].updateItemAt(num - 1, item);
          }
          
          var url = "http://www.appcelerator.com";
          var client = Ti.Network.createHTTPClient({
            onload : function(e) {
                check(true);
            },
            onerror : function(e) {
                check(false)
            },
            timeout : 30000  // 30sec
          });
        
          client.open("GET", url);
          client.send();
        }
        
  15. Eric Wieber 2018-02-22

    FR Passed. Tested using all of the sample and referenced tickets in the issue ticket as well as the module examples and http test suite
  16. Eric Wieber 2018-02-23

    Verified changes are included in SDK builds: 7.1.0.v20180222163802 & 7.2.0.v20180223044652

JSON Source