2011-04-27 91 views
1

我試圖讓這個插件工作,但它不會爲我工作。Phonegap系統通知插件

https://github.com/saileshmittal/phonegap-system-notification-plugin

我想我做得不對與調用JavaScript文件的插件。這是我迄今爲止;

 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"); 

}); 

我在做什麼錯?

+0

由於您明確調用了「onBackground」,我假設您也希望在應用程序處於前臺時獲取系統通知。你可以請把控制檯日誌創建...通知方法,看看它是否被調用?還要確保你正在做README所說的一切。 – Sailesh 2011-05-01 10:38:55

回答

0

經過一些調整後,立即工作;

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('', '', '');