Creating my own Cordova plugin

Creating my own Cordova plugin

  

Hi,

The user story is as follows:

It concerns a mobile application, in this case for Android (5.1). The OS platform is 10.0.408.0 (on-premises).  

I'm trying to create my own plugin, available not as a GitHub URL but as a ZIP file in Resources. First, I've created an application using a third party plugin - cordova-plugin-dialogs. I've created a module - a wrapper for this plugin - and used it a button. It works as expected - when I touch the button it displays some text using the native dialog. As far as good.

Then I've created an empty plugin, using the "plugman" application: plugman create ...... I've created another a wrapper module, in this module a resource with the appropriate ZIP file (attached TMLPlugin2.zip file) and I've configured it (Extensibility Configurations attribute) as:

{
    "resource": "TMLPlugin2.zip",
     "plugin": {
         "resource": "TMLPlugin2"
     }
}

In the main module I've ONLY added the reference to an empty public Action from the module containing TMLPlugin2. No use of any element of TMLPlugin2 module, only reference added. But after that my existing button stopped working: when I click it I get only a red message: "Cannot read property 'alert' of undefined. Clearly the whole cordova-plugin-dialogs object is gone.

I've no idea what I'm doing wrong. Can anybody give me some hint?

Regards

Tomasz

PS. My OS platform is 10.0.408.0 (on-premises). The target device is with Android 5.1.

Solution

Hi Tomasz,


Like we've discussed and just for the record, the resource attribute of plugin, requires the path for the plugin inside the zip, as described here.

So if you provide TMLPlugin2 as the resource it means that all the plugin file must be inside a folder called TMLPlugin2.


Thanks

Solution

João Carvalho wrote:

Hi Tomasz,


Like we've discussed and just for the record, the resource attribute of plugin, requires the path for the plugin inside the zip, as described here.

So if you provide TMLPlugin2 as the resource it means that all the plugin file must be inside a folder called TMLPlugin2.


Thanks

... and it's occured, that the path to the plugin's folder MUST start with the folder "plugin", e.g. plugin/TMLPlugin2. This completes the solution of this issue.

Regards

Tomasz