Announcing the Read it Later plugin for PhoneGap (soon also for Cordova)
One of the developers working on the new PhoneGap-based Wikipedia Mobile was having some annoying issues with the PhoneGap ShareKit plugin and decided he’d rather just put the Facebook and Twitter sharing in with their individual plugins.
He was happy with the decision where Facebook and Twitter were concerned, but lamented that the decision would mean there would no longer be support for Read it Later (http://readitlaterlist.com).
I had a look at Read it Later’s API and iOS SDK and it looked fairly straight forward, so when he asked if I would like to write a plugin for it I took on the challenge.
Just two hours later I had a shiny new PhoneGap plugin!
https://github.com/devgeeks/ReadItLaterPlugin
If you wanna be as cool as Wikipedia, run over to GitHub and clone it into your app now!
Installation
This plugin allows you to save a URL to Read It Later from your app.
Add the plugin much like any other:
- Add the ReadItLaterPlugin.h and VolumeSlider.m classes to your Plugins folder in Xcode (use “Create groups for any added folders”)
- Add the ReadItLaterPlugin.js file to your www folder
- Add the ReadItLaterPlugin.js to your html file. eg:
<script type="text/javascript" charset="utf-8" src="ReadItLaterPlugin.js"></script> - Add the plugin to the PhoneGap.plist under Plugins (key: “ReadItLaterPlugin” value: “ReadItLaterPlugin”)
Next, get the Read It Later API iPhone Library and add it to your project:
- Download the library from Read It Later
- Unzip the library and examples
- Copy these four files into your Xcode project under the Plugins folder (again, use “Create groups for any added folders”)
ReadItLaterLite.hReadItLaterLite.mReadItLaterFull.hReadItLaterFull.m
- Get an API Key from Read It Later for your app
- Add your shiny new API key to the top of the
ReadItLaterLite.mfile you copied in abovestatic NSString *apikey = @"<api key here>";
- Add the name of your app (as you entered it to get your API key above) as well
static NSString *nameOfYourApp = @"<name of your app here>";
Finally, call the saveToReadItLater() method using a success callback and an object containing a url and a title:
Example
function onDeviceReady()
{
var readItLaterPlugin = window.plugins.readItLaterPlugin;
readItLaterPlugin.saveToReadItLater(
function(){
console.log("Successfully saved to Read It Later");
},
{
url: "http://github.com/devgeeks",
title: "Devgeeks on GitHub"
}
);
}