简体   繁体   中英

Uncaught TypeError: Cannot read property 'statusBarNotification' of undefined

I'm using cordova 2.1.0, and am trying to add a notification to the status bar.

I'd included the related java files and js script into the project, and added the following line in the config.xml

<plugin name="StatusBarNotification" value="com.phonegap.plugins.statusBarNotification.StatusBarNotification"/>

In my html code, I'd added the following lines in my head tag

<script src="cordova-2.1.0.js"/>
<script src="statusbarnotification.js"/>

and at the bottom of the content div page, i'd added the following script

<script>
window.plugins.statusBarNotification.notify("Message Header", "Message details");
</script>

However when i run it in emulator for android 4.0, i'm hitting the error:

Uncaught TypeError: Cannot read property 'statusBarNotification' of undefined

Anyone has encounter this issue before?

Ok my bad, it's a false alarm. I have the script file put into a js folder rather in the same folder as the cordova js file. After renaming the script src path to the correct one it is working now. Can't believe i spent few hours on this!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM