首先是感谢国外大神DrewDahlman
参考地址:phonegap localNotification plugin update
GIT地址:https://github.com/DrewDahlman/Phonegap-LocalNotification
按照大神的方法,根据版本的不同,区分Cordova 1.7+和Phonegap
值得一提的是,我使用的版本cordova-2.1.0下,xcode运行报错,报的是映射的问题,那么可以打开Cordova.plist进行编辑,在Plugins下添加key和value都一样的“LocalNotification”即可
01 | //在添加一切引用后,一句话即可生效! |
02 | plugins.localNotification.add({ |
03 | date: new Date(), |
04 | message: 'This is a notification' , |
05 | badge: 1, |
06 | id: 123, |
07 | sound: 'sub.caf' , |
08 | background: 'app.background()' , |
09 | foreground: 'app.running()' |
10 | }); |
最近真是苦,国内资料太少,希望把我觉得好的东西分享给大家哈!