Uncaught ReferenceError: cordova is not defined, http://localhost:8100/lib/push.js, Line: 7 #98

Closed
siphiwe opened this Issue Sep 3, 2015 · 9 comments

Comments

Projects
None yet
2 participants
@siphiwe

siphiwe commented Sep 3, 2015

Hi there,

I'm trying to implement this plugin in my ionic project. The deprecated plugin worked ok but with the new one, where I have the following:

   <!--....-->
    <script src="cordova.js"></script>
    <script type="text/javascript" src="lib/push.js"></script>
   <!--....-->

I get this error:

Uncaught ReferenceError: cordova is not defined, http://localhost:8100/lib/push.js, Line: 7

Other plugins that use cordova don't have this issue. I installed it as a cordova plugin. Could it be that it's meant to be strictly phonegap? Any help would be appreciated. Thanks

@siphiwe siphiwe closed this Sep 3, 2015

@siphiwe siphiwe reopened this Sep 3, 2015

@macdonst

This comment has been minimized.

Show comment
Hide comment
@macdonst

macdonst Sep 3, 2015

Member

@siphiwe no, this plugin will work with either Cordova or PhoneGap. Are you adding it manually to your project or are you using the command line interface?

Member

macdonst commented Sep 3, 2015

@siphiwe no, this plugin will work with either Cordova or PhoneGap. Are you adding it manually to your project or are you using the command line interface?

@siphiwe

This comment has been minimized.

Show comment
Hide comment
@siphiwe

siphiwe Sep 3, 2015

Thanks for prompt response. I used the cli but copied push.js over into www/lib folder so the app can reference it. Not sure if anything else should've been copied. :-/

siphiwe commented Sep 3, 2015

Thanks for prompt response. I used the cli but copied push.js over into www/lib folder so the app can reference it. Not sure if anything else should've been copied. :-/

@macdonst

This comment has been minimized.

Show comment
Hide comment
@macdonst

macdonst Sep 3, 2015

Member

@siphiwe you should not need to copy the push.js over to your libs folder and add a script tag in your html file. The CLI on the prepare phase will copy the push.js file to the correct location in the platform directory and link it to your app. You should not need to do any manual steps.

Member

macdonst commented Sep 3, 2015

@siphiwe you should not need to copy the push.js over to your libs folder and add a script tag in your html file. The CLI on the prepare phase will copy the push.js file to the correct location in the platform directory and link it to your app. You should not need to do any manual steps.

@siphiwe

This comment has been minimized.

Show comment
Hide comment
@siphiwe

siphiwe Sep 4, 2015

Oh...? Thank you @macdonst
How does the app resolve it then? Is there some place I can read about how this works? I removed the script tag and indeed, the error's not there anymore but it seems I need to reference it some way else because I can't instantiate it, it throws "Uncaught ReferenceError: PushNotification is not defined"

siphiwe commented Sep 4, 2015

Oh...? Thank you @macdonst
How does the app resolve it then? Is there some place I can read about how this works? I removed the script tag and indeed, the error's not there anymore but it seems I need to reference it some way else because I can't instantiate it, it throws "Uncaught ReferenceError: PushNotification is not defined"

@macdonst

This comment has been minimized.

Show comment
Hide comment
@macdonst

macdonst Sep 4, 2015

Member

@siphiwe in the platform directory that you are trying to run in it's www directory there is a file called cordova_plugins.js and that is the plugins that get loaded when you run your app.

Sample setup:

cordova create pushtest
cd pushtest
cordova platform add android
cordova plugin add phonegap-plugin-push
// add your html/js to the www directory
cordova run android

Same thing applies to iOS of course.

Member

macdonst commented Sep 4, 2015

@siphiwe in the platform directory that you are trying to run in it's www directory there is a file called cordova_plugins.js and that is the plugins that get loaded when you run your app.

Sample setup:

cordova create pushtest
cd pushtest
cordova platform add android
cordova plugin add phonegap-plugin-push
// add your html/js to the www directory
cordova run android

Same thing applies to iOS of course.

@siphiwe

This comment has been minimized.

Show comment
Hide comment
@siphiwe

siphiwe Sep 5, 2015

Thanks for your trouble @macdonst
I think I need to read up more on how cordova works. Please recommend any good books or reference.At this point, I can't even test if I'm past this issue or not because I think I broke something else.

siphiwe commented Sep 5, 2015

Thanks for your trouble @macdonst
I think I need to read up more on how cordova works. Please recommend any good books or reference.At this point, I can't even test if I'm past this issue or not because I think I broke something else.

@macdonst

This comment has been minimized.

Show comment
Hide comment
@macdonst

macdonst Sep 7, 2015

Member

@siphiwe I'd go with John's book as it is relatively up to date:

http://www.amazon.ca/Apache-Cordova-Programming-Mobile-ebook/dp/B00VAJMIQO/ref=sr_1_1?ie=UTF8&qid=1441589298&sr=8-1&keywords=cordova

I'm going to close this issue for now but re-open if you have problems in the future.

Member

macdonst commented Sep 7, 2015

@siphiwe I'd go with John's book as it is relatively up to date:

http://www.amazon.ca/Apache-Cordova-Programming-Mobile-ebook/dp/B00VAJMIQO/ref=sr_1_1?ie=UTF8&qid=1441589298&sr=8-1&keywords=cordova

I'm going to close this issue for now but re-open if you have problems in the future.

@macdonst macdonst closed this Sep 7, 2015

@siphiwe

This comment has been minimized.

Show comment
Hide comment
@siphiwe

siphiwe Sep 7, 2015

Thanks a lot.

siphiwe commented Sep 7, 2015

Thanks a lot.

@lock

This comment has been minimized.

Show comment
Hide comment
@lock

lock bot Jun 5, 2018

This thread has been automatically locked.

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@phonegap phonegap locked as resolved and limited conversation to collaborators Jun 5, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.