【问题标题】:Phonegap system notification pluginPhonegap系统通知插件
【发布时间】:2011-04-27 19:19:15
【问题描述】:

我正在尝试让这个插件工作,但它对我不起作用。

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

});

我做错了什么?

【问题讨论】:

  • 由于您明确调用“onBackground”,我假设您也想在应用程序处于前台时获取系统通知。您能否将控制台日志放入 create...Notification 方法并查看它是否被调用?还要确保你按照自述文件所说的去做。

标签: android cordova


【解决方案1】:

经过一些调整,现在可以使用了;

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-28
    • 1970-01-01
    • 1970-01-01
    • 2017-11-20
    • 1970-01-01
    相关资源
    最近更新 更多