We recently added plugin support to WP7 PhoneGap apps. I will outline here what you need to do to start extending the functionality for WP7 PhoneGap projects.
All WP7 PhoneGap plugins must derive from the PhoneGap base command. More specifically, the WP7GapClassLib.PhoneGap.Commands.BaseCommand class.
I recently posted a plugin titled PGSimpleShare to my GitHub repo. You can clone/fork it here : https://github.com/purplecabbage/phonegap-plugins/tree/master/WindowsPhone/PGSocialShare
To call your native side implementation, simply call PhoneGap.exec(winCallbackFunction, failCallbackFunction, pluginName, methodName, argsObj); The WP7 version of PhoneGap.exec will do the work of managing your callbacks if supplied, as well as turning the argsObj into a JSON object that can be passed to your native code. In the case of the shareStatus function defined above, the framework, on the native side will look for a class named PGSocialShare. ( fully qualified: WP7GapClassLib.PhoneGap.Commands.PGSocialShare ) When it finds this class it will instantiate it if it hasn’t already, then it will attempt to call the ‘share’ method on it. Here is a portion of the native implementation of the ‘share’ function :
Note the implementation of the share function is public, returns void, and expects 1 string argument, this is currently the signature for ALL plugin methods that are callable via the framework.
The above code then continues on to deserialize the JSON representation of the arguments it is expecting via a data-contract. See the full source code for details on this.
Based on the shareType passed in, we will call another method in our class; namely ‘shareStatus’.
Hopefully this is enough for everyone to get started developing plugins for Windows Phone! Also, I have attempted to keep PGSocialShare device-agnostic in the definition of the methods, so hopefully we will see the same plugin implemented on other devices as well. I look forward to your comments, questions, and critriques!