HTML and CSS Reference
In-Depth Information
The new code begins with the var accelerationWatchId = null; variable setting. We
have created a startAccelerationWatch() function, which will call the onSuccess()
function every 100 milliseconds.
The onSuccess() function receives the “acceleration” values from the API, which consist
of delta changes to the x , y , and z of the device. These values are set to 0,0,0 when the
application begins.
On each 100 -millisecond interval, these values are checked. If any is 2 units greater (in
either the positive or negative direction) from the 0 beginning values, we fire off an
alert and then call our functions to reset the card. First, we call the stopAcceleration
Watch() function, which acts as a reset for the location of the device in physical space.
Next, we call the chooseButtonsForCard() and drawScreen() functions. Finally, we set
up the watch again with startAccelerationWatch() .
For the most detailed and up-to-date information on integrating
PhoneGap with iOS and other device features, visit the PhoneGap doc-
umentation website. Most of the information for this example is based
off the explanation and examples found at http://docs.phonegap.com/
phonegap_accelerometer_accelerometer.md.html .
Testing on a Device
Before we can test the application on an actual device, we need to “provision” the
device. To do this, we will need the device, a paid iOS developer account, and a de-
velopment Mac computer all synced up into a single provisioning profile. This neces-
sary process is not for the faint of heart.
Step 1: Launch the Provisioning Assistant
Begin by visiting the Developer Provisioning Assistant ( http://developer.apple.com/
iphone ) and logging in with your paid iOS developer ID. Once logged in, click on the
link for the “iOS Provisioning Portal” (currently in the upper-right side menu). There
should be a button called “Launch the Provisioning Assistant.” Click on this button
and follow all the on-screen instructions.
Step 2: Find the device's Unique ID
You will be asked to find the Unique ID of your physical device. This is found by
plugging the device into your computer, and then looking up the ID in Xcode. In the
Window Organizer Information window, you will see a list of the attached devices.
The ID will be a long alphanumeric string next to the word Identifier.
Search WWH ::




Custom Search