Cannot use Custom Plugin

2 posts, 0 answers
  1. kwanchanok
    kwanchanok avatar
    22 posts
    Member since:
    May 2014

    Posted 31 Jul 2014 Link to this post

    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
  2. Martin Yankov
    Admin
    Martin Yankov avatar
    177 posts

    Posted 05 Aug 2014 Link to this post

    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.

     
Back to Top