Modules.URLSession
> Modules.URLSession

Wrapper to support iOS's NSURLSession class for background downloads.

Requires: iOS 7.0.0 and later

These APIs are supported on iOS 7 and later.

The URL session module (com.appcelerator.urlSession) provides the application the ability to download large content via HTTP while the application is in the background. With this module, you can

  1. Create a URL session and a background download task.
  2. Monitor events to check the progress of the download and session.
  3. Cancel downloads and invalidate sessions.

URL session events are monitored through the following iOS application-level events:

These events are monitored as application-level events by using the addEventListener method with the Titanium.App.iOS namespace.

For more information on getting started, refer to the iOS Background Services guide.

  • 3.2.0
  • 3.2.0
Defined By

Properties

apiName : Stringreadonly

The name of the API that this proxy corresponds to.

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, Button returns Ti.UI.Button.

  • 3.2.0
  • 3.2.0
  • 3.2.0

The configuration used for this url session.

The configuration used for this url session.

Configuration options for an Modules.URLSession.Session object.
When a session is created, a copy of the configuration object is made. you cannot modify the configuration of a session after it has been created.

The shared session uses the global singleton credential, cache and cookie storage objects.

An ephemeral session has no persistent disk storage for cookies, cache or credentials.

A background session can be used to perform networking operations on behalf of a suspended application, within certain constraints.

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks will also be called on the proxy. Proxies that require the activity lifecycle will need this property set to the appropriate containing Window or TabGroup.

  • 3.6.0
Defined By

Methods

Applies the properties to the proxy. ...

Applies the properties to the proxy.

Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that myproxy[key] = value.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Parameters

  • props : Dictionary

    A dictionary of properties to apply.

Returns

  • void
Modules.URLSession
( session, url ) : Stringdeprecated
Creates a download task for the specified URL, within the provided session object and saves the results to a file. ...

Creates a download task for the specified URL, within the provided session object and saves the results to a file.

deprecated since 6.1.0

Use <Modules.URLSession.Session.downloadTask> on the session directly.

Once this function is called, the download starts automatically. The progress of the download can be monitored by listening to the downloadprogress, downloadcompleted, sessioneventscompleted and sessioncompleted events.

Parameters

  • session : Object

    URL session object.

  • url : String

    URL to download content from.

Returns

  • String

    Task's identifier number.

Modules.URLSession
( session )deprecated
Invalidates the given session object, allowing any outstanding tasks to finish. ...

Invalidates the given session object, allowing any outstanding tasks to finish.

deprecated since 6.1.0

Use <Modules.URLSession.Session.finishTasksAndInvalidate> (on the session object) instead.

This method returns immediately without waiting for tasks to finish. Once a session is invalidated, new tasks cannot be created in the session, but existing tasks continue until completion. Once invalidated, references to the events and callback objects are broken. Session objects cannot be reused. To cancel all outstanding tasks, call invalidateAndCancel instead.

Parameters

  • session : Object

    URL session object.

Returns

  • void
Gets the value of the apiName property. ...

Gets the value of the apiName property.

  • 3.2.0
  • 3.2.0
  • 3.2.0

Returns

  • String
Gets the value of the configuration property. ...

Gets the value of the configuration property.

Returns

Gets the value of the lifecycleContainer property. ...

Gets the value of the lifecycleContainer property.

  • 3.6.0

Returns

Modules.URLSession
( session )deprecated
Cancels all outstanding tasks and then invalidates the session object. ...

Cancels all outstanding tasks and then invalidates the session object.

deprecated since 6.1.0

Use <Modules.URLSession.Session.invalidateAndCancel> (on the session object) instead.

Once invalidated, references to the events and callback objects are broken. Session objects cannot be reused. To allow outstanding tasks to run until completion, call finishTasksAndInvalidate instead.

Parameters

  • session : Object

    URL session object.

Returns

  • void
Modules.URLSession
( configuration )
Sets the value of the configuration property. ...

Sets the value of the configuration property.

Parameters

Returns

  • void
Sets the value of the lifecycleContainer property. ...

Sets the value of the lifecycleContainer property.

  • 3.6.0

Parameters

Returns

  • void