|
| 1 | +--- |
| 2 | +name: Modules.URLSession.Session |
| 3 | +summary: The session object used to start new tasks. |
| 4 | +description: | |
| 5 | + These APIs are supported on iOS 7 and later. |
| 6 | +
|
| 7 | + The NSURLSession class and related classes provide an API for downloading content. |
| 8 | + This API provides a rich set of delegate methods for supporting authentication and gives |
| 9 | + your app the ability to perform background downloads when your app is not running or, in iOS, |
| 10 | + while your app is suspended. |
| 11 | +
|
| 12 | + [iOS Background Services guide](http://docs.appcelerator.com/titanium/latest/#!/guide/iOS_Background_Services). |
| 13 | +
|
| 14 | +extends: Titanium.Module |
| 15 | +osver: {ios: {min: "7.0"}} |
| 16 | +platforms: [iphone, ipad] |
| 17 | +since: 6.1.0 |
| 18 | + |
| 19 | +methods: |
| 20 | + - name: finishTasksAndInvalidate |
| 21 | + summary: Invalidates the given session object, allowing any outstanding tasks to finish. |
| 22 | + description: | |
| 23 | + This method returns immediately without waiting for tasks to finish. Once a session is invalidated, |
| 24 | + new tasks cannot be created in the session, but existing tasks continue until completion. Once |
| 25 | + invalidated, references to the events and callback objects are broken. Session objects cannot be |
| 26 | + reused. To cancel all outstanding tasks, call `invalidateAndCancel` instead. |
| 27 | +
|
| 28 | + - name: invalidateAndCancel |
| 29 | + summary: Cancels all outstanding tasks and then invalidates the session object. |
| 30 | + description: | |
| 31 | + Once invalidated, references to the events and callback objects are broken. |
| 32 | + Session objects cannot be reused. To allow outstanding tasks to run until |
| 33 | + completion, call `finishTasksAndInvalidate` instead. |
| 34 | + |
| 35 | + - name: downloadTask |
| 36 | + summary: | |
| 37 | + Creates a download task for the specified URL, within the provided session |
| 38 | + object and saves the results to a file. |
| 39 | + description: | |
| 40 | + Once this function is called, the download starts automatically. The progress |
| 41 | + of the download can be monitored by listening to the `downloadprogress`, |
| 42 | + `downloadcompleted`, `sessioneventscompleted` and `sessioncompleted` events. |
| 43 | + parameters: |
| 44 | + - name: args |
| 45 | + summary: An object representing the arguments to add a new background task. |
| 46 | + type: DownloadTaskType |
| 47 | + returns: |
| 48 | + summary: Task's identifier number. |
| 49 | + type: String |
| 50 | + |
| 51 | + - name: uploadTask |
| 52 | + summary: | |
| 53 | + Creates a upload task for the specified URL, within the provided session |
| 54 | + object and local data. |
| 55 | + description: | |
| 56 | + Once this function is called, the upload starts automatically. The progress |
| 57 | + of the upload can be monitored by listening to the `uploadprogress` and |
| 58 | + `sessioncompleted` events. |
| 59 | + parameters: |
| 60 | + - name: args |
| 61 | + summary: An object representing the arguments to add a new upload task. |
| 62 | + type: UploadTaskType |
| 63 | + returns: |
| 64 | + summary: Task's identifier number. |
| 65 | + type: String |
| 66 | + |
| 67 | + - name: reset |
| 68 | + summary: Empties all cookies, cache and credential stores, removes disk files, calls <Modules.URLSession.Session.flush>. |
| 69 | + parameters: |
| 70 | + - name: callback |
| 71 | + summary: Callback to be invoked when the reset completes. |
| 72 | + type: Callback |
| 73 | + |
| 74 | + - name: flush |
| 75 | + summary: Flushes storage to disk and clear transient network caches. |
| 76 | + parameters: |
| 77 | + - name: callback |
| 78 | + summary: Callback to be invoked when the reset completes. |
| 79 | + type: Callback |
| 80 | + |
| 81 | +properties: |
| 82 | + - name: configuration |
| 83 | + summary: The configuration used for this url session. |
| 84 | + description: | |
| 85 | + Configuration options for an <Modules.URLSession.Session> object. |
| 86 | + When a session is created, a copy of the configuration object is made. |
| 87 | + you cannot modify the configuration of a session after it has been created. |
| 88 | + |
| 89 | + The shared session uses the global singleton credential, cache |
| 90 | + and cookie storage objects. |
| 91 | + |
| 92 | + An ephemeral session has no persistent disk storage for cookies, |
| 93 | + cache or credentials. |
| 94 | + |
| 95 | + A background session can be used to perform networking operations |
| 96 | + on behalf of a suspended application, within certain constraints. |
| 97 | + optional: false |
| 98 | + availability: creation |
| 99 | + type: Modules.URLSession.SessionConfiguration |
| 100 | + |
| 101 | +--- |
| 102 | +name: DownloadTaskType |
| 103 | +summary: The parameter for [downloadTask](Modules.URLSession.Session.downloadTask) method. |
| 104 | +properties: |
| 105 | + - name: url |
| 106 | + summary: The remote url used for this data task. |
| 107 | + type: String |
| 108 | + |
| 109 | +--- |
| 110 | +name: UploadTaskType |
| 111 | +summary: The parameter for [uploadTask](Modules.URLSession.Session.uploadTask) method. |
| 112 | +properties: |
| 113 | + - name: url |
| 114 | + summary: The remote url used for this data task. |
| 115 | + type: String |
| 116 | + optional: false |
| 117 | + |
| 118 | + - name: data |
| 119 | + summary: The data blob used for this data task. |
| 120 | + type: Titanium.Blob |
| 121 | + optional: false |
| 122 | + |
| 123 | + - name: method |
| 124 | + summary: The request method (e.g. POST or PUT) |
| 125 | + default: POST |
| 126 | + type: String |
| 127 | + |
| 128 | + - name: requestHeaders |
| 129 | + summary: Additional request headers to pass to the request. |
| 130 | + type: String |
0 commit comments