Post on 31-May-2020
© 2012 Adobe Systems Incorporated. All Rights Reserved.
PhoneGap Native Plugins Yeah… it can do that.
© 2012 Adobe Systems Incorporated. All Rights Reserved.
Who is this guy?
Andrew Trice Technical Evangelist, Adobe
atrice@adobe.com
h!p://tricedesigns.com
@andytrice
h!p://github.com/triceam
All external content obtained via creative commons or public domain.
© 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
© 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
© 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.
© 2012 Adobe Systems Incorporated. All Rights Reserved.
OK, how does that work?
All external content obtained via creative commons or public domain.
© 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.
© 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.
© 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.
© 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.