How to: Learn How to Integrate your Website as an Ubuntu Web App

How to: Learn How to Integrate your Website as an Ubuntu Web App

In Ubuntu 12.10, Canonical and the Ubuntu development team introduced Ubuntu web apps – websites that can be integrated into the Launcher and Dash for easy access, and for extra features including interfacing with the notification system in Ubuntu, and so forth.

It’s very simple to get started with integrating your website as an Ubuntu web app. It’s as simple as adding the following JavaScript code to your website:

function unityInit()
 {
 // Executed after integration and each time app is run
 }

 var Unity = external.getUnityObject(1.0);
Unity.init({name: "Title of your web app",
 iconUrl: "URL for icon in the Launcher and Dash",
 onInit: unityInit});

The unityInit() function is executed when the user accepts the integration notification and each time they run the web app. With those simple lines of code, your website / web application will allow Ubuntu 12.10 users (and prior Ubuntu users with the web app packages installed) to install your web app as if it was a standalone Ubuntu application.

Each time an end user who has your web app installed visits your website, the web app icon will appear on the Launcher. They can lock the app icon to the Launcher just like an ordinary Ubuntu application, and search for it via the Dash at any time.

Using Unity Notifications.

To execute a Unity notification, use the showNotification() method.

Unity.Notification.showNotification("Title of notification",
"Body of notification");

Other things you can do.

You can integrate HUD (Heads-Up Display) actions. The HUD is invoked by pressing the Alt key,

and allows you to search for menu options without having to use your mouse or trackpad. For example, to create a new tab, you can hit Alt and type new tab to create a new tab in the browser you are using. As with web apps, you can integrate certain functions as HUD options for users to make use of.

For web-based chat and mail web apps, those can be integrated into the Ubuntu Messaging Menu, just as if it was like a native Ubuntu application like Empathy Internet Messaging and Pidgin IM.

Again, all interfacing as an Ubuntu web app is done via JavaScript.

Find out more.

To learn more about Ubuntu web apps as a developer, see the official Ubuntu web apps reference information here.

The entire API reference for Ubuntu web apps can be found here.

Visit the Webhosting UK website for more news, knowledge base articles, blog posts and information on our wide range of hosting services.

Sharing

Pin It on Pinterest

Share This