Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

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

@siphiwe
Copy link

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 as completed Sep 3, 2015
@siphiwe siphiwe reopened this Sep 3, 2015
@macdonst
Copy link
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
Copy link
Author

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
Copy link
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
Copy link
Author

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
Copy link
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
Copy link
Author

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
Copy link
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 as completed Sep 7, 2015
@siphiwe
Copy link
Author

siphiwe commented Sep 7, 2015

Thanks a lot.

@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot 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.
Labels
None yet
Development

No branches or pull requests

2 participants