Custom Plugins Don't Work

4 posts, 0 answers
  1. Nathaniel
    Nathaniel avatar
    7 posts
    Member since:
    Feb 2015

    Posted 06 Nov 2015 Link to this post

    I've been trying with no luck to install third-party Cordova plugins.

    I've followed the Telerik guides and downloaded the plugins and then added them from archive into my app so they are listed under the plugins.

    However, when I run my app, the JavaScript that should call the plugin throws an error. Upon further inspection in the Chrome Dev Tools, I noticed that my plugins are not listed in the plugins source folder and none of them are loaded in cordova_plugins.js.

    The plugins I tested were:

    https://github.com/aquto/cordova-plugin-AppleAdvertising

    https://github.com/praves77/cordova-plugin-android-idfa

    http://plugins.telerik.com/cordova/plugin/screenorientation

    Since the last plugin in the previous list has a demo available, I tested the demo app and the plugin works as expected. But when I copy the steps in the Screen Orientation plugin inside my own app, the plugin doesn't work.

    Am I missing a step? Any tricks to getting third-party plugins to work?

    Thanks!

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 11 Nov 2015 Link to this post

    Hi Nathaniel,

    As to benefiting from custom cordova plugins, you should first import the one you are interested it. Would you try following the next steps:
    1. Download ZIP containing the plugin details from the plugin repository.
    2. Open the project solution and
    - right-click on Plugins
    - select Import and browse to add the downloaded .zip file
    - right-click on Properties, select Open and choose the Plugins tab to ensure the plugin is added under Other Plugins section.

    For some more detailed explanations, you can also refer to the documentation on Import Custom Plugins.

    Having done this, you can configure the screen orientation for the app in code:
    // rotate and lock orientation to portrait window.screen.lockOrientation('portrait'); // rotate and lock orientation to landscape window.screen.lockOrientation('landscape');

    You can also get an actual information on this setting:
    alert("Current orientation: " + window.screen.orientation);

    Doesn't this work for you? In case there are still some issues on your side, would you please share with us your project so that we can check it locally? A detailed explanation of the expected behavior will also be very helpful.

    Regards,
    Dimitrina
    Telerik
     

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

     
  3. Nathaniel
    Nathaniel avatar
    7 posts
    Member since:
    Feb 2015

    Posted 11 Nov 2015 in reply to Dimitrina Link to this post

    Hello Dimitrina,

    Yes, I followed these steps and the plugin is listed under Other Plugins. Still it doesn't appear to be loaded into the app.

     alert("Current orientation: " + window.screen.orientation); comes back as undefined.

    What is the best way to privately share my project so you can check it?

    Thank you.

  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Nov 2015 Link to this post

    Hello,

    Would you ensure you make an attempt to invoke the code after the device is ready? For the purpose, I would suggest you to try the following:
    1. subscribe for the deviceready event handler
    2. ensure the Screen Orientation plugin is enabled (through General Project Properties
    3. add 
    the code to get current orientation on deviceready

    In case there is still an issue, please open a support ticket to provide specific information and share the project to be treated privately. In that way, a dedicated support engineer can assist you further and you can get access to the full benefits of the support services.

    Regards,
    Dimitrina
    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