Metro Nuggets

Bitesized Windows Phone 7, Windows Phone 8 and Windows 8 tidbits

Sharing Links To Pocket (formerly Read It Later)

Pocket is a brilliant service that allows you to essentially bookmark links and (as the old name suggests), read it later. Pocket has no official app on the Windows Phone platform, but there are more apps coming from other sources (including my own Squirrel).

One of the things each of the apps has in common (other than being a Pocket client), is the ability to add links to Pocket from other apps. This is done using a custom URI scheme and works as expected. The only problem is, if you’re writing an app that you’d like to add Pocket support to, what do you do? Do you pledge your allegiance to one app? What if your users are using a different Pocket app? What then?

This was a problem I decided to address whilst writing my own Pocket app.

The Solution

I got in touch with a couple of other developers who I knew to have written (or be writing) Pocket clients and put the same arguments to them and suggested a standardised URI scheme that all our apps would use, which would mean third party apps can add Pocket integration without having to choose a Pocket client to align themselves with.

Fortunately, the other developers agreed and so we set about creating this standardised scheme and a solution that would help aid other developers to easily add Pocket integration into their app.

And so PocketWP was born.

PocketWP is a helper library that will help two different types of developers: those writing an app that wants Pocket integration, and those writing Pocket apps who want to make use of the standardised scheme.

Adding Pocket Integration

In its simplest form, you can send a link to a Pocket client by adding this line of code:

PocketHelper.AddItemToPocket("http://www.getpocket.com");

But there are other options, like adding Tweet ID, or tags, and even multiple items (although that’s up to the clients to have implemented this).

Using the Pocket Scheme

In the WMAppManifest file, you’ll need to add a Protocol tag in the Extensions section, it should be this:

<Protocol Name="pocket" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />

PocketWP offers you helper methods in order to get the information being passed from the other app. So, for example, in your own UriMapper, you might have something like the following:

if (PocketHelper.HasPocketData(uri))
{
    var item = PocketHelper.RetrievePocketData(uri);

    // Save the item somewhere for use within your app
    return new Uri("AddItemPage.xaml", UriKind.Relative);
}

PocketWP is available from nuget:
PocketWPNuget

Apps that currently support receiving via this method are: Squirrel (going through certification), Pouch, and Poki (in development).

SL

About these ads

One response to “Sharing Links To Pocket (formerly Read It Later)

  1. Pingback: Windows App Developer Links – 2014-01-07 | Dan Rigby

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: