Detect if in simulator

7 posts, 0 answers
  1. Ned
    Ned avatar
    32 posts
    Member since:
    Jul 2013

    Posted 03 Nov 2014 Link to this post

    So, I used to use if (window.device.name) to check if I was in a simulator or a native device. But, you guys are now passing all of the device info so the simulator thinks it's a real device! Nice. So, is there another way to check if I'm on a device or in the simulator? I need this to handle not loading some plugins that error out when on the simulator (AdMob etc). Thanks!
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 03 Nov 2014 Link to this post

    Hello Ned,

    You can use the following code to check if your app is running in the device simulator:
    checkSimulator: function() {
        if (window.navigator.simulator === true) {
            alert('This plugin is not available in the simulator.');
            return true;
        } else if (window.plugins === undefined || window.plugins.AdMob === undefined) {
            alert('Plugin not found. Maybe you are running in AppBuilder Companion app which currently does not support this plugin.');
            return true;
        } else {
            return false;
        }
    }

    Let me know if that helps.

    Regards,
    Tina Stancheva
    Telerik
     

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

     
  3. Ned
    Ned avatar
    32 posts
    Member since:
    Jul 2013

    Posted 03 Nov 2014 in reply to Tina Stancheva Link to this post

    Hmm, simulator is not defined. I'm using appbuilder-cli on osx.
  4. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 04 Nov 2014 Link to this post

    Hi Ned,

    The simulator property is something we add dynamically when you run your project in the simulator. This is why if the app is running outside the AppBuilder device simulator, the property will be undefined.

    If, however, the property is undefined when you run the app in your simulator, we will need to examine your app or a sample app where the issue reproduces. Only then we will be able to investigate the cause behind the error.

    Regards,
    Tina Stancheva
    Telerik
     

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

     
  5. Kamlesh
    Kamlesh avatar
    2 posts
    Member since:
    Oct 2015

    Posted 11 Jan in reply to Tina Stancheva Link to this post

    Hi Tina,

    I'm using telerik app builder and plugin 'Printer-master' from https://github.com/katzer/cordova-plugin-printer

    When I check to printer available than, error like : Plugin not found. Maybe you are running in AppBuilder Companion app which currently does not support this plugin.

    I can't understand it. please help.

  6. Kamlesh
    Kamlesh avatar
    2 posts
    Member since:
    Oct 2015

    Posted 13 Jan in reply to Kamlesh Link to this post

    Sorry, I forgot these steps.

    Run -> Build -> Android-> App package

    After following these, success.

    Thanks.

  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 13 Jan Link to this post

    Hi Kamlesh,

    Currently the AppBuilder companion app and the AppBuilder device simulator don't support custom plugins. I believe this was the cause for the behavior you experienced. You can check the following articles for a complete list of the supported plugins within the companion app and the device simulator:
    Let me know if you have more questions.

    Regards,
    Tina Stancheva
    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