Touch2Share
By tapping one device against the other, the webOS 3.0 Touch2Share feature allows a user to share a URL between two Touch2Share-enabled devices. On the receiving device, the browser application is launched to this URL. The Seamless Transitions (ST) service - com.palm.stservice - implements this functionality.
On the sending device, a foreground application interacts with the ST service to initiate data transfer. This app must be running full-screen (not carded).
Bluetooth Connection
The data is sent over a Bluetooth connection. If Bluetooth is off, the user sees a message to turn Bluetooth on and tap again.
To implement Touch2Share:
- Add the following to your app's
appinfo.jsonfile :
"tapToShareSupported": true
-
In your Enyo app, create an
onApplicationRelaunchapplication event handler that checks for aparams.sendDataToShareparameter (see example). -
If the parameter exists, call the ST service's
shareDatamethod to send the URL to the target device.
shareData
Transfers data betweeen sending application and target device.
Syntax
{
data : {
"target" : string,
"mimetype" : string,
"type" : string
}
}
Parameters
| Parameter | Required | Type | Description |
| data | Yes | object | Data to be sent. See fields below. |
| target | Yes | string | URL to launch broswer to. |
| mimetype | Yes | string | Currently, only "text/html". |
| type | Yes | string | Currently, only "rawdata". |
Returns
{
returnValue : boolean
}
| Attribute | Required | Type | Description |
| returnValue | Yes | boolean |
true (success) or false (failure)
|
Example
Enyo
// In sending application
enyo.kind({
name : "enyo.touch2share",
kind : enyo.VFlexBox,
components : [
{kind: "ApplicationEvents", onApplicationRelaunch: "applicationRelaunchHandler"},
{ flex : 1,
kind : "Pane",
components : [{
flex : 1,
kind : "Scroller",
components : [
{
name : "sendData",
kind : "PalmService",
service : "palm://com.palm.stservice",
method : "shareData",
onSuccess : "sendDataSuccess",
onFailure : "sendDataFailure",
subscribe : true
}
]
}]
}],
applicationRelaunchHandler: function(inSender) {
var params = enyo.windowParams;
if (params.sendDataToShare !== undefined) {
dataToSend = { "target": "http://www.google.com", "type": "rawdata", "mimetype": "text/html"};
this.$.sendData.call({"data": dataToSend});
return true;
}
},
sendDataSuccess: function(inSender, inResponse) {
this.log("Send data, results=" + enyo.json.stringify(inResponse));
},
// Log errors to the console for debugging
sendDataFailure: function(inSender, inError, inRequest) {
this.log(enyo.json.stringify(inError));
}
});