May 10

This is a walkthrough of creating a webOS mobile app using PhoneGap 0.9.5. If you’ve previously created webOS apps using older versions of PhoneGap; you will notice that the biggest difference with PhoneGap 0.9.5 is that the Mojo framework is no longer required to author webOS apps.

The first couple steps are to make sure you have all the tools and to set up your project.

  1. The list of necessary software & tools listed in step 3 on the PhoneGap webOS page.
  2. Set up your project by following step 4 on the PhoneGap webOS page, be sure to leave your terminal/cygwin window open as you will need it later.

From here you can delete or rename the index.html file (if you want to keep it as a reference) in the framework folder, we will be working on creating an app from the beginning.

  1. Create a new index.html file in the framework folder.
  2. Include the phonegap.js library in the of your index.html
  3. Add an onLoad method which triggers the navigator.device.deviceReady() method in the right after the reference to phonegap.js
  4. In the tag’s onload event call the onLoad() method
  5. Add the text “Hello World” within the tags

The source of your index.html should look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
<html>
    <head>
        <script type="text/javascript" src="phonegap.js"></script>
        <script type="text/javascript">
            function onLoad() {
                navigator.device.deviceReady();
            }
        </script>
    </head>
    <body onload="onLoad();">
        Hello World
    </body>
</html>

To view your work, you’ll want to either:

  • open the Palm emulator
  • set your Palm device to developer mode and plug it in

Go back to terminal/cygwin and type “make” (without the quotes).

Presto! You should see your hello world example app in the emulator or device.

PhoneGap webOS Hello World Example

Source can be found here.

2 Responses to “Getting Started with PhoneGap WebOS 0.9.5”

  1. Sebastian Says:

    Hey,

    First, thx for the tutorial!
    Question: does your app work in Chrome/Safari ?
    Since 0.9.5.(1) i am getting the following error msgs:

    Mojo already exists. Make sure to remove it from your index.html
    phonegap.js:1200Uncaught ReferenceError: PalmServiceBridge is not defined

    and yes it has been removed from the index.html

  2. Herm Wong Says:

    Hi Sebastian, the error msg that you are referring to can be ignored – it’s actually left over from PhoneGap 0.9.4 which relied on the Mojo framework. I will need to remove the check & error for the next PhoneGap release.

Leave a Reply