Introduction to Web Intents

Paul Kinlan (@paul_kinlan)
G+: plus.ly/paul.kinlan

Jan Kleinert (@jankleinert)
G+: plus.ly/jan.kleinert

What's the problem?

Imagine integrating all these services!

Sharing

Pick

Editing

Saving

Authentication

There is a solution in the works

Web Intents

Web Intents is a framework for client-side service discovery and inter-application communication

How does it work?

  1. Service registers its intention to handle an action for the user
  2. App requests to start an action (share, edit, pick, ...)
  3. User selects which service to handle the action

Sound familiar?

Simple Sharing Demo

<intent
   action="http://webintents.org/share"
   type="image/*"
   href="shareimage.html" >

When launched, data on:

window.intent

Service: I provide a sharing service

var intent = new Intent("http://webintents.org/share", 
                        "text/uri-list", 
                        window.location.href);
window.navigator.startActivity(intent);

Client App: I need a sharing service

Action

var intent = new Intent("http://webintents.org/share", 
                        "text/uri-list", 
                        window.location.href);
window.navigator.startActivity(intent);

A verb.

Type

var intent = new Intent("http://webintents.org/share", 
                        "text/uri-list", 
                        window.location.href);
window.navigator.startActivity(intent);

A description of the data being used

Data

var intent = new Intent("http://webintents.org/share", 
                        "text/uri-list", 
                        window.location.href);
window.navigator.startActivity(intent);

The data by value or reference (URL)

Can be complex types such as images, audio or documents

And then what?

Nothing! You've just integrated your apps and services

But there's more...

We can do two-way communication

Client:

var intent = new Intent("http://webintents.org/pick", "image/*");
window.navigator.startActivity(intent, function(intentData) {
// Do something with the response
});

Service:

window.intent.postResponse({  ... some data ...  });

Demo - cloud file picker

var intent = new Intent("http://webintents.org/pick", "image/*");
window.navigator.startActivity(intent, function(intentData) {
var pickedImage = document.getElementById("picked");
pickedImage.src = intentData.data;
});

We can do long-lived connections*

* - next version of the shim

Client:

var channel = MessageChannel();
var intent = new Intent("http://webintents.org/pick", 
 "image/*",
 channel.port1);
window.navigator.startActivity(intent);

Service:

window.intent.postResponse({  ... some data ...  });

Demo

PAUL CLICK THIS!!

Behind the firewall

http://www.flickr.com/photos/dhabben/2779511984/
This will change the way we build apps on the web - Paul Kinlan

How to get started?

JavaScript Shim

<script src="http://webintents.org/webintents.min.js"></script>

Examples

examples.webintents.org

Contribute!

webintents.org/#contributing

What's coming next?

Thank you!

webintents.org

groups.google.com/group/web-intents

We want your feedback! What are your use cases?