Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

Onsen 2 - Monaca CLI - Cordova plugins weird behavior

  • I recently started using Onsen-UI 2 and with it Monaca CLI tools. It’s a pretty awesome tool, very helpful. There is one or two niggles I’ve picked up though, although I think I can solve most of them by looking at migration guides.

    The biggest issue that I can’t seem to figure out is the plugins. I create my app (Plain JS Onsen 2.0 app) with the Monaca CLI, and then proceed to use normal cordova commands to add my platforms and plugins. Don’t ask me why, I just like it that way. When building for iOS I get build “Success” status and my app runs fine in emulator and on my device. The issue is when I try to use features provided by plugins (custom, 3rd party plugins).

    I tried implementing the plugin (installed successfully) and my app launches just fine. I have a function that fires on device ready to check whether or not the plugin is working, a “canScan” function, that shows an alert with the result. However, even though the device is ready, nothing happens. The weird behavior is this: when I put the app in the background, or open multitasking window (double tap home button) and then come back to the app, then the alert shows up with the message that I can scan. After receiving this message, I should be able to tap a button and the interface should appear, but again, nothing happens when I tap the button. Only if I do the same as before (enter multitasking and come back to the app) then the interface appears, but freezes the app.

    I thought there was an issue with my implementation of the plugin, i.e. my code is wrong, but this happens with other plugins too.

    Any ideas as to what is going on here?

    This is my “onDeviceReady” function:

    document.addEventListener('deviceready', function() {
    }, false);

    This is how I installed the plugin:

    $ cordova plugin add <plugin-name>

    I also tried installing the plugin via the Monaca tools:

    $ monaca plugin add <plugin-name>

    Any help or advice will be greatly appreciated!

    PS: Asked an identical question on Stack Overflow, but no responses yet.