2015-01-29

Build a Todo Chrome App

https://developer.chrome.com/apps/app_codelab_intro
 

Along the way, you will learn:
  • How to create, run, and debug a Chrome App in Step 1.
  • How to update an existing web app as a Chrome App, deal with Content Security Policy issues, and add local storage support in Step 2.
  • How to implement alarms and notifications in Step 3.
  • How to display web pages inline in Step 4.
  • How to load resources (like images) from external sources in Step 5.
  • How to write to a file in the native filesystem in Step 6.
  • How to publish your app to the Chrome Web Store in Step 7.

Step 1:Create and Run a Chrome App


Step 2:Import an Existing Web App

Reload your app now (right-click > Reload App). You should see the basic UI but you won't be able to add todos.
The solution is simple: move the inline content to a new file.
1. Near the bottom of index.html, remove the inline JavaScript and instead include js/bootstrap.js:
2. Create a file in the js folder named bootstrap.js. Move the previously inline code to be in this file:
You'll still have a non-working Todo app if you reload the app now but you're getting closer.
Chrome Apps do not support localStorage as localStorage is synchronous. Synchronous access to blocking resources (I/O) in a single-threaded runtime could make your app unresponsive.
Chrome Apps have an equivalent API that can store objects asynchronously. This will help avoid the sometimes costly object->string->object serialization process.
To address the error message in our app, you need to convert localStorage to chrome.storage.local.

Step 3:Add Alarms and Notifications


Step 4:Open External Links With a Webview

Step 5:Add Images From the Web

Step 6:Export Todos to the Filesystem

Step 7:Publish Your App


No comments:

Post a Comment