Cordova plugin not loading in app

Hi,

I have imported the Cordova Media Recorder plugin and added a Javascript in accordance with the plugin's documentation. In testing on IOS I'm getting an error that says "undefined is not an object (evaluating 'navigator.mediaDevices.getUserMedia')".

At first I thought it might be an error in the JS but in looking at the log I now suspect the cordova plugins I added might have been loaded only after my JS has been loaded - does plugins load before JS or after?

I have also tried adding other cordova plugins (through resources and then ticking them on in App Settings) but it all doesn't seem to be connected when the app is tested on my IOS device. Can you please help? I have been stuck with this issue for over 2 weeks now. Thanks.
1 person has
this question
+1
Reply
  • Hunter,

    In order to use a plugin - you must wait until AFTER the device ready event has fired.

    On your ‘main’ screen - here’s an event that you can tie this to - and fire any code from there.

    Also - in terms of IOS testing - make sure you’re testing with an ipa and not on the Appery tester.

    A good way to test almost any plugin and the required code to drive it - it through the Weinre debugger.

    I have videos on using Weinre to test with as well as a number of posts here on the forum that might help.

    If you’re Hunter F. - shoot me a mail or text me - happy to help gratis.

    Best,
    Bruce
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited

  • Hi Bruce

    Much thanks for your reply, that was very helpful.

    I was indeed testing on IOS using my iPad and not on the Appery tester. Couldn't seem to get Weinre debugger to work so I used Safari tech preview to check the logs from my device.

    I added a device ready event on my main page (log says it fired) and then inserted my JS immediately after, but I'm still getting "TypeError: undefined is not an object (evaluating 'navigator.mediaDevices.getUserMedia')", which is indicative that my Phonegap Media Recorder may not have loaded correctly at all, although the cordova plugin list suggests otherwise.

    Any idea? I'm not Hunter F though but would be really grateful for any help! Thanks.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited

  • Hi Hunter ,

    Thanks for the note back - how about emailing me a couple of times and the timezone you are in ? Be happy to help no charge . Email address Bruce.stuart@ the-Software-studio.com ...

    Best,
    Bruce
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited

  • Hi Bruce

    Just an update - I managed to solve the issue on Saturday, turns out it was an issue with Device Ready after all! Have set it on DeviceReady event in Appery (rather than onLoad) and it finally worked! Thanks so much for pointing me to the right direction.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited