Development Tips when using PhoneGap Build Plugins

Plugins are an incredibly useful way to bring native functionality to PhoneGap apps. Once you start including them though, complexity can skyrocket, mainly because you are now dependent on actual devices to test. This can lead to frustration as feedback loops are increased. To help shorten these, follow these tips:

Practice safe programming practices: add a check that the plugin exists before attempting to use it: 

if (window.plugins !== undefined && window.plugins.myPlugin !== undefined) {

// safe to use plugin now


Without those, app may unexpectedly crash/become unresponsive.

Read the plugin documentation carefully. It’s easy to miss a required parameter (especially with JavaScript’s lack of static typing), setup steps, or even object casing (“gaPlugin” vs. “GAPlugin”). Also beware that the docs may be out of date - if you are following instructions perfectly but still have trouble try checking the plugin’s open issues section if available. Oftentimes out of date documentation has been noticed by someone else, but the project leader hasn’t accepted the pull request that fixes it yet. I’ve had this happen two separate times!

Use various tools to troubleshoot issues.

a. Local debugging: Open the app in a browser locally - are there script errors or other issues that may make the plugin issue a red herring?

b. Remote debugging: Add extra console logging messages and exception handling to narrow down the issue directly.

Are there any other tips that I should add? Let me know below.

Learn how to create mobile apps with JavaScript. Get occasional PhoneGap/Cordova and Ionic tips, tutorials, and more:

comments powered by Disqus