This is a migrated thread and some comments may be shown as answers.

Cannot use Custom Plugin

1 Answer 81 Views
AppBuilder extension for Visual Studio
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
kwanchanok
Top achievements
Rank 1
kwanchanok asked on 01 Aug 2014, 04:46 AM
i have to use custom plugin https://github.com/edewit/aerogear-crypto-cordova . i following in http://docs.telerik.com/platform/appbuilder/creating-your-project/using-plugins/using-custom-plugins/add-includes

1. import to Plugins Folder
2. Modify plugin.xml to " ​ <asset src="www/aerogear.crypto.js" target="aerogear.crypto.js" /> "
and remove 
<js-module src="www/aerogear.crypto.js" name="AeroGear">
    <clobbers target="AeroGear"/>
  </js-module>

3. i run in simulator and show error

Failed to load resource: the server responded with a status of 404 (Not Found) http://local/Simulator/aerogear.crypto.js

1 Answer, 1 is accepted

Sort by
0
Martin Yankov
Telerik team
answered on 05 Aug 2014, 02:29 PM
Hello Kwanchanok,

If a custom plugin has been defined in a <js-module> element in the plugin.xml, you do not need to reference it in your index.html. The plugin object is added automatically to the global window object once the deviceready event has fired. The name of the plugin object is the same as the clobbers target of the <js-module> element. In your case the clobber's target is AeroGear, so you can access the plugin by window.AeroGear once the deviceready event has fired.

Restore the plugin.xml to its original state and just use the plugin like so:

onDeviceReady: function () {
    var agCrypto = new window.AeroGear.Crypto();
    agCrypto.deriveKey('my password', null, {
        success: function (rawPassword) {
            console.log(rawPassword);
        }
    });
}

Another thing I should mention is that custom plugins cannot work in the AppBuilder Simulator. You should test them only on a real device.

I have attached a working project for reference. It alerts the raw password on app start.

Let me know should you have any other questions or experience further problems.

Regards,
Martin Yankov
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
AppBuilder extension for Visual Studio
Asked by
kwanchanok
Top achievements
Rank 1
Answers by
Martin Yankov
Telerik team
Share this question
or