Maker Faire - May 2013
Presented by Don Coleman / @doncoleman
PhoneGap is an open source solution for building cross-platform mobile apps with standards-based Web technologies like HTML, JavaScript, CSS.
iOS, Android
Windows Phone, Blackberry
Symbian, Bada, WebOS
Tizen, FirefoxOS
Windows 8, OS X, Chrome
Your app is a native app
PhoneGap does not provide a UI
Single Page App
Unzip archive
move somewhere like /usr/local/phonegap-2.7.0
Do you have platform tools installed?
Xcode
Android SDK
Visual Studio
BlackBerry Webworks SDK
Android
$ cd /usr/local/phonegap-2.7.0
$ cd lib/android
$ .bin/create ~/foo com.example.foo Foo
$ cd ~/foo
$ ./cordova/run
PhoneGap Getting Started Guides
http://docs.phonegap.com/en/2.7.0/guide_getting-started_index.md.htmlindex.html
<!DOCTYPE html>
<html>
...
<script src="cordova-2.7.0.js"></script>
<script src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
</body>
</html>
index.js
var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener(
'deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
// your code here
}
};
API Example - Camera
navigator.camera.getPicture(cameraSuccess, cameraError, options);
http://docs.phonegap.com/en/2.7.0/cordova_camera_camera.md.html
Callbacks
function cameraSuccess(imageURI) {
image.src = imageURI;
}
function cameraError(message) {
alert('Failed because: ' + message);
}
API Call
navigator.camera.getPicture(
cameraSuccess,
cameraError,
{
quality: 50,
destinationType: Camera.DestinationType.FILE_URI
}
);
Permissions
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Lots of other APIs
http://docs.phonegap.com/en/2.7.0/index.htmlBut PhoneGap doesn't do
[insert your feature here]
Extend PhoneGap
var macAddress = "00:00:AA:BB:CC:DD";
var connected = function() {
// connected, do something
};
var disconnected = funtion(error) {
// disconnected
};
bluetoothSerial.connect(macAddress, connected, disconnected);
var onMessage = function(data) {
console.log(data);
};
bluetoothSerial.subscribe("\n", onMessage, onFailure);
bluetoothSerial.write("Hello Arduino");
Don Coleman
PhoneGap for Makers by Don Coleman is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at http://github.com/don/slides/2013-05-19-phonegap-for-makers.