[TIMOB-27821] ti.urlsession - Event sessioncompleted does not get all specified values
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-08-11T15:01:31.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.1.0 |
Components | n/a |
Labels | n/a |
Reporter | Mikael Norrman |
Assignee | Vijay Singh |
Created | 2020-03-18T10:15:21.000+0000 |
Updated | 2020-08-11T15:01:31.000+0000 |
Description
I'm using the module [ti.urlSession](https://github.com/appcelerator-modules/ti.urlsession) to fetch data in the background.
The issue is that when the download is complete and the event "sessioncompleted" fires, the input argument object doesn't contain all the values specified in the [documentation](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.App.iOS-event-sessioncompleted), it's missing success, errorCode, message, responseText and statusCode. Basically all attributes connected to the http response.
To test this I set up a test application:
*index.js*
var URLSession = require("com.appcelerator.urlSession");
function doClick(e) {
alert($.label.text);
var sessionConfig = URLSession.createSessionConfiguration({identifier: "test"});
var session = URLSession.createSession({configuration: sessionConfig});
var task = session.downloadTask({url: "http://ip.jsontest.com"});
}
Ti.App.iOS.addEventListener('downloadcompleted', function(e) {
console.log('download complete', JSON.stringify(e));
if (e.data) {
console.log(e.data.text);
}
});
Ti.App.iOS.addEventListener('sessioncompleted', function(e) {
console.log('Session complete', JSON.stringify(e));
});
$.index.open();
*index.html*
<Alloy>
<Window class="container">
<Label id="label" onClick="doClick">Hello, World</Label>
</Window>
</Alloy>
And this is the output that I get from running the application and tapping on the label:
{noformat}
[INFO] : download complete {"sessionIdentifier":"test","taskIdentifier":1,"data":{},"bubbles":true,"type":"downloadcompleted","source":{},"cancelBubble":false}
[INFO] : {"ip": "5.150.230.124"}
[INFO] : Session complete {"taskIdentifier":1,"sessionIdentifier":"test","bubbles":true,"type":"sessioncompleted","source":{},"cancelBubble":false}
{noformat}
I had this working last in Ti SDK 7.4.1.v20180927102822
[~mnorrman] Did this same module version work with older SDK's? Or did an upgrade of the module break it?
I'm pretty sure the same version (2.2.0) was working in TiSDK 7.4.1 but not in TiSDK 8+
This is regression , introduced in SDK 7.5.0, due to PR https://github.com/appcelerator/titanium_mobile/pull/8860.
PR - https://github.com/appcelerator/titanium_mobile/pull/11782 Test Case (Download task)-
Test Case (Data Task) -
Note - @QE Need to verify the event parameters are accordance with document. e.g 1. In download task 'sessioncomplete' will have 'statusCode' as well but no 'responseText'. 2. In dataTask it will have both properties
FR Passed, waiting on Jenkins build
merged to master for 9.1.0 target
*Closing ticket*. Improvement verified in SDK version
9.1.0.v20200810120239
. *Test and other information can be found at:* https://github.com/appcelerator/titanium_mobile/pull/11782