Navigator.Camera is missing

6 posts, 1 answers
  1. Pete OK
    Pete OK avatar
    5 posts
    Member since:
    Dec 2014

    Posted 07 Jan 2015 Link to this post

    Hello,

    I've added the camera plugin to my project in AppBuilder.  When I view in the simulator, it shows that the Camera.js file has been loaded in the plugins folder, but navigator.camera doesn't exist.  When I set a breakpoint to see if it's firing, the Camera.js page is never called.  I also tried compiling it into a debug package and loaded it on an iPhone and Android and navigator.camera don't exist for either.  (I've also tried removing and readding the plugin to my project multiple times, but that didn't work.)

    Help?


    Thanks.
  2. Pete OK
    Pete OK avatar
    5 posts
    Member since:
    Dec 2014

    Posted 07 Jan 2015 Link to this post

    I was eventually able to get the camera to pull on my iPhone.  I think I've narrowed it down to the simulator only. I'm also using the Push Notification plugin, which doesn't run in the simulator.  But what I think is happening is that because the PushNotification plugin is not supported and produces an error, then the plugins that normally would be loaded after it are not loaded, and the camera is one of them.  Is there a way to catch and handle that Push Notification plugin load error that happens during Cordova initialization, so that it doesn't stop the loading of the subsequent plugins?
  3. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 08 Jan 2015 Link to this post

    Hi Pete,

    If the PushPlugin in the simulator is causing the issue, you can use the window.navigator.simulator object to check if you re running the app on a simulator:
    if (window.navigator.simulator === true){
    //running in the simulator, don't access the PushPlugin
    }
    else{
    //running on a device
    }
    If the object's value is false you can go ahead and access the push plugin, if not - invoke only the plugins available in the simulator.

    However, your report suggests that there is an issue with the Media plugin even when your app runs directly on a device. If that is indeed the case, we would need a sample reproducing this behavior in order to further investigate the case. 

    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.

     
  4. Pete OK
    Pete OK avatar
    5 posts
    Member since:
    Dec 2014

    Posted 14 Jan 2015 in reply to Tina Stancheva Link to this post

    Hi Tina, thanks for the followup.  I am using the conditional code for my push interactions, and put breakpoints in to verify that my code is never being called.  The error (for me) is popping up on line 1371 of cordova.js, which is trigger by an original call in line 1600 of cordova.js within the function injectIfNecessary() which attempts to load the PushPlugin, fails (as expected), but then the error is not caught (at least within Chrome), and so the loading of all plugins after PushPlugin is halted (including the camera, which for me is coming after PushPlugin).

    On my test devices, I have been able to verify that the PushPlugin and the Camera plugins are working fine, and I'm able to test the camera functionality there (albeit a lot slower).  I had found a bug in my code that I was able to fix, so on device testing works, but simulator testing still does not work.  So this does seem to be isolated to the cordova loading in the simulator only.

    Thanks.
  5. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 16 Jan 2015 Link to this post

    Hello Pete,

    The device simulator does not support custom plugins, which includes the PushPlugin. This is why Cordova throws an error - it cannot locate the plugin and run its native code in the simulator. The problem here, however goes further as we haven't put any logic in to handle the error and you are currently unable to continue working within the app once the PushPlugin is used.

    We will do our best to address this case by creating a mock-up of the PushPlugin in the device simulator so that Cordova does not throw an error stopping your application's further execution. At this point I am not sure when this fix will be released but I have escalated and prioritized the task and we will try to address it for our next major release.

    In the meantime, please avoid testing the Push plugin in the in-browser client simulator. Also, do let me know if there is anything that I am missing from your report.

    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.

     
  6. Pete OK
    Pete OK avatar
    5 posts
    Member since:
    Dec 2014

    Posted 16 Jan 2015 in reply to Tina Stancheva Link to this post

    Thanks!  That's all I really need.  Don't need support for the Push Plugin.  Just need it to not crash the Camera plugin that is supported.

    In the meantime I guess I'll just remove push from my project properties while I'm testing Camera actions in the simulator, and just remember to put it back before I do the next build to native.

    Thanks again!
Back to Top