You are reading 12.6.1. See this page in 13.4.1.
Titanium.WatchSession
Extends Titanium.ModuleTitanium.Proxy
Used to enable data and file transfers between a watchOS and iOS application.
WatchSession enables data and file transfers between a WatchKit application and a Titanium application using the iOS Watch Connectivity framework introduced in iOS 9 and watchOS 2.
Properties 15
The watch is currently activated.
The watch is currently inactive.
The watch is currently not activated.
Returns the current activation state of the watch.
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
Inherited from Titanium.Proxy
Indicates if the proxy will bubble an event to its parent.
Default: true
Returns true if there is more content for the session to deliver.
Returns true if the watch is currently activated.
Returns true if complication is enabled on the installed watch app.
Returns true if the device is paired with a watch.
Returns true if the watch is currently reachable.
Returns true if the device supports watch connectivity.
Returns true if the accompanying watch app is installed.
The most recent application context sent to the watch app.
The number of calls remaining to transferCurrentComplication before the system starts
transferring the complicationUserInfo as regular userInfos.
Default: 0
Methods 13
Activates the watch session
Activates the watch session to make the app ready to receive messages from the watch app.
Inherited from Titanium.Proxy
Adds the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to invoke when the event is fired. 4 fields
|
applyProperties
since 3.0.0Inherited from Titanium.Proxy
Applies the properties to the proxy.
| Parameters | Type | Description |
|---|---|---|
| props | Dictionary | A dictionary of properties to apply. |
Cancels all incomplete file transfers to the apple watch.
Cancels all incomplete file transfers to the apple watch.
Cancels all incomplete transfers to the apple watch.
Cancels all incomplete transfers to the apple watch, including user info, complication and file.
Cancels all incomplete user info and complication transfers to the apple watch.
Cancels all incomplete user info and complication transfers to the apple watch.
Inherited from Titanium.Proxy
Fires a synthesized event to any registered listeners.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| event? | Dictionary | A dictionary of keys and values to add to the Titanium.Event object sent to the listeners. |
Inherited from Titanium.Proxy
Removes the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to remove. Must be the same function passed to 4 fields
|
Sends a message to the apple watch.
Sends a message to the installed watchapp on the apple watch in the foreground.
| Parameters | Type | Description |
|---|---|---|
| message | Dictionary | Message to send to apple watch. This property is required and the key of the dictionary needs to be a String. |
| reply? | Callback<MessageReply> | Function to be called upon receiving a reply from the watch app. Since Release 5.1.0 This function is used to process the direct reply from the watch app after sending one. 4 fields
|
Transfers complication data to the watch application.
Transfers complication data to the installed watch app. This is only for watch apps with complications enabled.
| Parameters | Type | Description |
|---|---|---|
| params | Dictionary | Complication to be transferred to watch app. |
Transfers a file to the apple watch.
Transfers a file to the installed watchapp on the apple watch in the background. Subsequent transfers are queued.
| Parameters | Type | Description |
|---|---|---|
| params | Dictionary | Pass an object with the following key-value pairs:
|
Transfers an user info to the apple watch.
Transfers an user info object to the installed watchapp on the apple watch in the background. Subsequent transfers are queued.
| Parameters | Type | Description |
|---|---|---|
| params | Dictionary | userInfo to be transferred to apple watch. |
Sends an app context update to the apple watch.
Sends an app context update to the apple watch. If watchapp is in background during transfer, watchapp will fire the Titanium.WatchSession.receiveapplicationcontext event immediately when it becomes active. Only one app context is stored at any one time. Subsequent updates will simply replace the earlier one sent.
| Parameters | Type | Description |
|---|---|---|
| params | Dictionary | App context to be updated in apple watch. |
Events 11
Called when the session has completed activation. If session state is Titanium.WatchSession.ACTIVATION_STATE_NOT_ACTIVATED there will be an error with more details.
| Event properties | Type | Description |
|---|---|---|
| isPaired | Boolean | If the device is paired with the apple watch. |
| isReachable | Boolean | If apple watch is currently reachable. |
| isWatchAppInstalled | Boolean | If the watch app is installed in the apple watch. |
| isComplicationEnabled | Boolean | If the complication is enabled in the apple watch. |
| isActivated | Boolean | If the apple watch is currently activated. Only available on iOS 9.3 and later. See Titanium.WatchSession.isActivated for more infos. |
| activationState | Number | Returns the current activation state of the watch. Only available on iOS 9.3 and later. See Titanium.WatchSession.activationState for more infos. |
Called when all events for the previously selected watch has occurred. The session can be re-activated for the now selected watch using activateSession.
| Event properties | Type | Description |
|---|---|---|
| isPaired | Boolean | If the device is paired with the apple watch. |
| isReachable | Boolean | If apple watch is currently reachable. |
| isWatchAppInstalled | Boolean | If the watch app is installed in the apple watch. |
| isComplicationEnabled | Boolean | If the complication is enabled in the apple watch. |
| isActivated | Boolean | If the apple watch is currently activated. Only available on iOS 9.3 and later. See Titanium.WatchSession.isActivated for more infos. |
| hasContentPending | Boolean | If the apple watch has currently content pending. Only available on iOS 10.0 and later. See Titanium.WatchSession.hasContentPending for more infos. |
| remainingComplicationUserInfoTransfers | Boolean | If the apple watch has complication userInfo transfers left. Only available on iOS 10.0 and later. See Titanium.WatchSession.remainingComplicationUserInfoTransfers for more infos. |
| activationState | Number | Returns the current activation state of the watch. Only available on iOS 9.3 and later. See Titanium.WatchSession.activationState for more infos. |
App completed file transfer to watch app.
| Event properties | Type | Description |
|---|---|---|
| fileURL | String | URL of the file transferred. |
| metaData | Dictionary | meta data of the file transferred. |
| success | Boolean | If the transfer was successful. |
| errorCode | Number | Error code if transfer failed. |
| message | String | Error message if any. |
Fired when the application completed user info transfer to the watch app.
| Event properties | Type | Description |
|---|---|---|
| userInfo | Dictionary | The downloaded data as a Titanium.Blob object. |
| success | Boolean | If the transfer was successful. |
| errorCode | Number | Error code if transfer failed. |
| message | String | Error message if any. |
Called when the session can no longer be used to modify or add any new transfers and, all interactive messages will be cancelled, but events for background transfers can still fire. This will happen when the selected watch is being changed.
| Event properties | Type | Description |
|---|---|---|
| isPaired | Boolean | If the device is paired with the apple watch. |
| isReachable | Boolean | If apple watch is currently reachable. |
| isWatchAppInstalled | Boolean | If the watch app is installed in the apple watch. |
| isComplicationEnabled | Boolean | If the complication is enabled in the apple watch. |
| isActivated | Boolean | If the apple watch is currently activated. Only available on iOS 9.3 and later. See Titanium.WatchSession.isActivated for more infos. |
| activationState | Number | Returns the current activation state of the watch. Only available on iOS 9.3 and later. See Titanium.WatchSession.activationState for more infos. |
The watch reachability state has changed.
| Event properties | Type | Description |
|---|---|---|
| isPaired | Boolean | If the device is paired with the apple watch. |
| isReachable | Boolean | If apple watch is currently reachable. |
| isWatchAppInstalled | Boolean | If the watch app is installed in the apple watch. |
| isComplicationEnabled | Boolean | If the complication is enabled in the apple watch. |
| isActivated | Boolean | If the apple watch is currently activated. Only available on iOS 9.3 and later. See Titanium.WatchSession.isActivated for more infos. |
| activationState | Number | Returns the current activation state of the watch. Only available on iOS 9.3 and later. See Titanium.WatchSession.activationState for more infos. |
App received app context from apple watch. Will be called on startup if an applicationContext is available.
| Event properties | Type | Description |
|---|---|---|
| applicationContext | Dictionary | The application Context |
App received file from apple watch in background.
| Event properties | Type | Description |
|---|---|---|
| data | Titanium.Blob | The downloaded data as a Titanium.Blob object. |
| metaData | Dictionary | Information about the file. |
| success | Boolean | If the transfer was successful. |
| errorCode | Number | Error code if transfer failed. |
| message | String | Error message if any. |
App received message from apple watch in foreground. Will be called on startup if the incoming message caused the receiver to launch.
| Event properties | Type | Description |
|---|---|---|
| message | Dictionary | The message content |
App received user info from apple watch in background. Will be called on startup if the user info finished transferring when the receiver was not running.
| Event properties | Type | Description |
|---|---|---|
| userInfo | Dictionary | The user info content |
The watch state has changed.
| Event properties | Type | Description |
|---|---|---|
| isPaired | Boolean | If the device is paired with the apple watch. |
| isReachable | Boolean | If apple watch is currently reachable. |
| isWatchAppInstalled | Boolean | If the watch app is installed in the apple watch. |
| isComplicationEnabled | Boolean | If the complication is enabled in the apple watch. |
| isActivated | Boolean | If the apple watch is currently activated. Only available on iOS 9.3 and later. See Titanium.WatchSession.isActivated for more infos. |
| activationState | Number | Returns the current activation state of the watch. Only available on iOS 9.3 and later. See Titanium.WatchSession.activationState for more infos. |