Weinre: troubleshoot mobile and remote apps

1) Install it if you haven’t yet:

$npm install weinre -g

2) run it:

$ weinre -boundHost [your ip address here or localhost]

3) Put the following reference in the page you are trying to troubleshoot:

<script src=”http//[the ip address you entered]:8080/target/target-script.js#anonymous”></script>

4) Point your browser to the ip address you entered, that will give you the firebug kind of debugger:

http://[localhost or ip address]:8080/



phonegap: accelerometer code

function testAccel() {
navigator.accelerometer.getCurrentAcceleration(accelSuccess, allError);

function accelSuccess(acceleration) {
var element = document.getElementById(‘accel’);
element.innerHTML = ‘Acceleration X: ‘ + acceleration.x + ‘<br />’ +
‘Acceleration Y: ‘ + acceleration.y + ‘<br />’ +
‘Acceleration Z: ‘ + acceleration.z + ‘<br />’ +
‘Timestamp: ‘ + acceleration.timestamp + ‘<br />’;

phonegap: geolocation code

navigator.geolocation.getCurrentPosition(geoSuccess, allError);

function geoSuccess(position) {
var element = document.getElementById(‘geoApi’);
element.innerHTML = ‘Getting ready to print the data’;
element.innerHTML = ‘Latitude: ‘ + position.coords.latitude + ‘<br />’ +
‘Longitude: ‘ + position.coords.longitude + ‘<br />’ +
‘Altitude: ‘ + position.coords.altitude + ‘<br />’ +
‘Accuracy: ‘ + position.coords.accuracy + ‘<br />’ +
‘Altitude Accuracy: ‘ + position.coords.altitudeAccuracy + ‘<br />’ +
‘Heading: ‘ + position.coords.heading + ‘<br />’ +
‘Speed: ‘ + position.coords.speed + ‘<br />’ +
‘Timestamp: ‘ + new Date(position.timestamp);

function allError(errors){

// Your errors here


Phonegap: avoid the build pain and suffering

Ok, part of the pain at least…

You still need to own (or access to) a Mac. And to pay the $99 fee to the Gods of Apple, and all the initial stuff to gather your Apple mobile developer certificate and your provisioning file.

But once you have those two, head to: https://build.phonegap.com/ and sign up for a free acct. Then, instead of building locally, upload your index.html file (which is the canvas of your app), and they take care of building the app for you in several different mobile apps, and give you the files or the QR reader code needed to download them to the phone you sign up for provisioning. No hassle. No pain.

You can only have one app at a time (unless you pain), but heck! it is free as in beer, and it works really good.

With the command line, things have become easier to implement:


Once you install:

$sudo npm install -g phonegap

You can create a new app:

$phonegap create [your app dir] [your app name]

And build:

$cd [your app dir]

$phonegap build ios

That will build the project locally, but the true timesaver is to use build.phonegap.com to do the work for you. In order to do that, you need
to login to your phonegap acct first.
$phonegap remote login -u iamreallyadog@gmail.com -p mYpASSw0RD

And now, to build remotely:
$phonegap remote build ios

If you get an error about invalid keys at this point, is because you need to provide one for your acct to work. Instructions here:

The process is a bit confusing and crazeee, but it basically involves creating a request for a signed certificate in your local env:

and then, in the apple developer portal, a certificate (from the file created locally), and a provisioning file, and then download both to your local env, and using Keychain access / export you create a .p12 file, then you upload that and the provisioning file to your phonegap account (to create a sign key), and you are done. The key is going to ask for a password to unlock it before you can use it.

Once you finish building, you can use the scanner image to load it to your phone, or download the code to it from the Adobe website.

If you need to install plugins:

$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration.git

For the complete list, see the Adobe build page.

Note: if you are using external js libraries or you need to hit external urls, you need to whitelist them in your config.xml file (follow this instructions):


Specifically, you need these two:

<access origin=”*.googleapis.com” />

<access origin=”*.gstatic.com” />