10
© 2012 Adobe Systems Incorporated. All Rights Reserved. PhoneGap Native Plugins Yeah… it can do that.

PhoneGap Native Plugins - Andrew Tricetricedesigns.com/wp-content/uploads/2012/03/PhoneGap-Native-Plugins.pdf© 2012 Adobe Systems Incorporated. All Rights Reserved. PhoneGap Native

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: PhoneGap Native Plugins - Andrew Tricetricedesigns.com/wp-content/uploads/2012/03/PhoneGap-Native-Plugins.pdf© 2012 Adobe Systems Incorporated. All Rights Reserved. PhoneGap Native

© 2012 Adobe Systems Incorporated. All Rights Reserved.

PhoneGap Native Plugins Yeah… it can do that.

Page 2: PhoneGap Native Plugins - Andrew Tricetricedesigns.com/wp-content/uploads/2012/03/PhoneGap-Native-Plugins.pdf© 2012 Adobe Systems Incorporated. All Rights Reserved. PhoneGap Native

© 2012 Adobe Systems Incorporated. All Rights Reserved.

Who is this guy?

Andrew Trice Technical Evangelist, Adobe

[email protected]

h!p://tricedesigns.com

@andytrice

h!p://github.com/triceam

All external content obtained via creative commons or public domain.

Page 3: PhoneGap Native Plugins - Andrew Tricetricedesigns.com/wp-content/uploads/2012/03/PhoneGap-Native-Plugins.pdf© 2012 Adobe Systems Incorporated. All Rights Reserved. PhoneGap Native

© 2012 Adobe Systems Incorporated. All Rights Reserved.

What is PhoneGap?

All external content obtained via creative commons or public domain.

  Application container that allows you to build natively installed apps using HTML, CSS & JavaScript

h!p://www.phonegap.com

Page 4: PhoneGap Native Plugins - Andrew Tricetricedesigns.com/wp-content/uploads/2012/03/PhoneGap-Native-Plugins.pdf© 2012 Adobe Systems Incorporated. All Rights Reserved. PhoneGap Native

© 2012 Adobe Systems Incorporated. All Rights Reserved.

OK, so what OS features does PhoneGap expose?

All external content obtained via creative commons or public domain.

http://phonegap.com/about/features

Page 5: PhoneGap Native Plugins - Andrew Tricetricedesigns.com/wp-content/uploads/2012/03/PhoneGap-Native-Plugins.pdf© 2012 Adobe Systems Incorporated. All Rights Reserved. PhoneGap Native

© 2012 Adobe Systems Incorporated. All Rights Reserved.

But what if you want more?

  PhoneGap is extensible with a “native plugin” model that enables you to write your own native logic to access via JavaScript.

All external content obtained via creative commons or public domain.

Page 6: PhoneGap Native Plugins - Andrew Tricetricedesigns.com/wp-content/uploads/2012/03/PhoneGap-Native-Plugins.pdf© 2012 Adobe Systems Incorporated. All Rights Reserved. PhoneGap Native

© 2012 Adobe Systems Incorporated. All Rights Reserved.

OK, how does that work?

All external content obtained via creative commons or public domain.

Page 7: PhoneGap Native Plugins - Andrew Tricetricedesigns.com/wp-content/uploads/2012/03/PhoneGap-Native-Plugins.pdf© 2012 Adobe Systems Incorporated. All Rights Reserved. PhoneGap Native

© 2012 Adobe Systems Incorporated. All Rights Reserved.

OK, how does that work?

  In JavaScript: PhoneGap.exec()   PhoneGap.exec(success, fail,

”NameOfClassMapping”, ”nameOfFunction", [url]);

All external content obtained via creative commons or public domain.

Page 8: PhoneGap Native Plugins - Andrew Tricetricedesigns.com/wp-content/uploads/2012/03/PhoneGap-Native-Plugins.pdf© 2012 Adobe Systems Incorporated. All Rights Reserved. PhoneGap Native

© 2012 Adobe Systems Incorporated. All Rights Reserved.

OK, how does that work?

In native code: use PGPlugin and PluginResult classes.

iOS: PluginResult* pluginResult = [PluginResult

resultWithStatus:PGCommandStatus_OK messageAsString: result];

[self writeJavascript: [pluginResult toSuccessCallbackString: self.callbackID]];

All external content obtained via creative commons or public domain.

Page 9: PhoneGap Native Plugins - Andrew Tricetricedesigns.com/wp-content/uploads/2012/03/PhoneGap-Native-Plugins.pdf© 2012 Adobe Systems Incorporated. All Rights Reserved. PhoneGap Native

© 2012 Adobe Systems Incorporated. All Rights Reserved.

OK, how does that work?

In native code: use PGPlugin and PluginResult classes.

Android: public PluginResult execute(String action,

JSONArray data, String callbackId){

//do something

result = new PluginResult(Status.OK);

return result;

}

All external content obtained via creative commons or public domain.

Page 10: PhoneGap Native Plugins - Andrew Tricetricedesigns.com/wp-content/uploads/2012/03/PhoneGap-Native-Plugins.pdf© 2012 Adobe Systems Incorporated. All Rights Reserved. PhoneGap Native

© 2012 Adobe Systems Incorporated. All Rights Reserved.

But what if you want more?

  "ere are lots of open source plugins at h!ps://github.com/phonegap/phonegap-plugins

  Learn more at h!p://wiki.phonegap.com/w/page/36752779/PhoneGap%20Plugins

All external content obtained via creative commons or public domain.