Android Phonegap系统通知插件
我试图让这个插件工作,但它不会为我工作 我认为我在Javascript文件中调用插件时出错了。这就是我目前所拥有的Android Phonegap系统通知插件,android,cordova,Android,Cordova,我试图让这个插件工作,但它不会为我工作 我认为我在Javascript文件中调用插件时出错了。这就是我目前所拥有的 var not_title = 'MELVIN'; var not_text = 'Zou dit werken?'; var not_tText = 'of toch niet?'; navigator.systemNotification.onBackground(); //navigator.systemNot
var not_title = 'MELVIN';
var not_text = 'Zou dit werken?';
var not_tText = 'of toch niet?';
navigator.systemNotification.onBackground();
//navigator.systemNotification.onForeground();
navigator.systemNotification.createStatusBarNotification(not_title, not_text, not_tText);
//navigator.systemNotification.updateNotification(not_title, not_text, 1);
这是SystemNotification.js底部的内容
PhoneGap.addConstructor(function () {
if (typeof(navigator.systemNotification) == "undefined") {
navigator.systemNotification = new SystemNotification();
navigator.systemNotification.touch(); //this ensures that the plugin is added when phonegap kicks off
}
//PhoneGap.addPlugin("systemNotification", new systemNotification());
PluginManager.addService("systemNotification", "com.SystemNotification.SystemNotification");
});
我做错了什么?经过一些调整后,它现在可以工作了
PhoneGap.addConstructor(function () {
PhoneGap.addPlugin("SystemNotification", new SystemNotification());
PluginManager.addService("SystemNotification", "com.phonegap.plugins.SystemNotification.SystemNotification");
window.plugins.SystemNotification.touch();
});
window.plugins.SystemNotification.onBackground();
window.plugins.SystemNotification.createStatusBarNotification('', '', '');
由于您显式地调用了“onBackground”,所以我假设您希望在应用程序也位于前台时获得系统通知。你们能不能把控制台日志放到create…Notification方法中,看看它是否被调用?还要确保你做的都是自述文件上说的。