This is a migrated thread and some comments may be shown as answers.

Cordova plugin not working

2 Answers 171 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Antoine
Top achievements
Rank 1
Antoine asked on 12 May 2017, 03:15 PM

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 Answers, 1 is accepted

Sort by
0
Antoine
Top achievements
Rank 1
answered on 12 May 2017, 03:45 PM
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
0
Anton Dobrev
Telerik team
answered on 17 May 2017, 09:42 AM
@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
Tags
General Discussions
Asked by
Antoine
Top achievements
Rank 1
Answers by
Antoine
Top achievements
Rank 1
Anton Dobrev
Telerik team
Share this question
or