Add to the Safari Reading List

Building an app that views, shares, or interacts with web content? If so you should consider providing offline content access to your users through the native Reading List feature in Safari. This can be done by using the Ti.Safari.ReadingList native module in just a few lines of code.

First you need to install the module, into your Titanium project. You can download the module here, and install using instructions for the Appcelerator Wiki located here.

After you’ve installed the module, you need to require the module into your project similar to the below snippet.

You are now ready to start adding Safari Reading List entries. To do so, just call the Add method on the module and provide a url, title, and optional previewText as shown in the below example.

The module will return a JavaScript dictionary with a success flag, and the contents you provided. If the success flag is false, you can check the message property of the dictionary for error details. The next time the user launches Safari, your contents will be downloaded for offline reading.

If you’d like to see the module in action, a video walk through of included sample app is available here. To the Ti.Safari.ReadingList module is available on github, along with the example app and documentation.

Ben Bahrenburg is an author, blogger, and technologist in PricewaterhouseCoopers’s International Assignment Services (IAS) practice. Ben is an Appcelerator Titanium Titan (Community Leader) and is a passionate advocate of cross-platform development in the Enterprise.


Comments

  • Nicolas B.

    What about showing a working example ?

  • Malcolm Hollingsworth

    What part of the code examples above did you feel were insufficient?

  • Nicolas B.

    Well, I see the example2.js, but I was looking for a page running this script. So that I be able to run it in Safari.

  • Malcolm Hollingsworth

    This code is not run using Safari, it is only ever run inside your app. It is designed to add new items to the reading list.

    Using this module your app can let your app user add content from within your app or someone else’s url as a new entry in Safaris Reading List.

    When your user is next inside Safari – that new content entry will appear inside the reading list for them to read. This is a great convenience feature and gives your app another opportunity to share content – but this time directly with themselves.

  • Nicolas B.

    “This code is not run using Safari, it is only ever run inside your app.”

    This is what I have guessed in the meantime. But it was not clear at all.