Chapter 8. Creating custom plugins
This chapter covers
- Why you’d write your own plugins
- The basic architecture of plugins
- How to build a sample Android plugin
In the past few chapters you’ve made use of a variety of plugins. Plugins to use the camera. Plugins to provide notifications. Plugins for globalization. You’ve also seen that an entire directory, (http://plugins.cordova.io) containing over 700 different plugins, exists.
But with all those choices, there’s still a strong chance you may encounter a need that isn’t covered by an existing plugin. Or perhaps a plugin exists, but it performs poorly and hasn’t been kept up to date. Perhaps the iPhone 9 is released with an incredible new feature—a cowbell. This feature is available to folks building native applications, but there’s no hook yet to use it with Cordova. A plugin would let you have access to this cool new feature. No matter the reason, one day you may need to create your own plugin.
Let’s review the basic architecture of how plugins work, shown in figure 8.1.