Cordova plugin not working

3 posts, 0 answers
  1. Antoine
    Antoine avatar
    6 posts
    Member since:
    Sep 2014

    Posted 12 May Link to this post

    Hello.

    I started a new mobile Cordova Hybrid project on the telerik platform

    I added the toast plugin from the marketplace and the streaming media plugin manually.

    Unfortunately none of them is working. Even if I try an exemple like this window.plugins.toast.showShortTop('Hello there!', function(a){console.log('toast success: ' + a)}); I get the following error : Uncaught TypeError: Cannot read property 'toast' of undefined

    When I look in the console, window.plugins is empty.

    Why are there no plugin in my window object ?

     

    Thanks

     

    index.js:49 Uncaught TypeError: Cannot read property 'toast' of undefined
    index.js:49 Uncaught TypeError: Cannot read property 'toast' of undefined
    index.js:49 Uncaught TypeError: Cannot read property 'toast' of undefined
  2. Antoine
    Antoine avatar
    6 posts
    Member since:
    Sep 2014

    Posted 12 May in reply to Antoine Link to this post

    Ok when reusing code from the toast demo on the Cordova app it's okay. My bad. Must be a similar error with streaming media plugin
  3. Anton Dobrev
    Admin
    Anton Dobrev avatar
    599 posts

    Posted 17 May Link to this post

    @Antoine

    Glad to hear you've got this working. 

    Usually you need to pay attention to the plugin API (some may be using other global objects and not window.plugins) and ensure that you are calling the plugin methods after the deviceready eventis called. 

    The latter is the most frequent problem for getting such errors as you experienced. 

    Regards,
    Anton Dobrev
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top