nodeValue
: Object - the registration value to store in the node.nodeValue.label
: String - a title/label to distinguish this application.nodeValue.icon
: String - a URL path to an icon to distinguish this application.To register to handle an intent, the register
action is used.
When registering an intent handler, two entity properties are used to make choosing a handler easier for the end user:
When a label/icon is not provided, the page title of the widget is used as the label and the icon will default to a predefined default icon.
var config = {
"label": "My JSON Viewer",
"icon": "https://www.example.com/icon.png"
};
var onInvoke = function(payload) {
return someWidgetFunction(payload);
};
var viewRef = new iwc.intents.Reference("/application/json/view");
viewRef.register(config, onInvoke);
If the registration node path matches /{minor}/{major}/{action}
("/application/json/view") the handler Id will be
generated automatically and returned in the promise resolution.
If the registration node path matches /{minor}/{major}/{action}/{handlerId}
("/application/json/view/123") the
handler Id given will be used.
The registration promise resolution does not handle the intent invocation, rather reports the status of the registration:
{
"resource": "/application/json/view/3229d7e2"
}
The resource
property of the response is the node that was used for the handler. To unregister simply
delete said node:
intentsApi.delete("/application/json/view/3228d7e2");
The callback registered with the register
action can return any serialized value (stirng,number,bool,object). The
value that is returned will be sent back to the IWC client that called invoke
.