Phonegap / Cordova中的本地通知

问题描述 投票:0回答:2

我想在Phonegap上使用本地通知。我使用phonegap-plugin-local-notification 1.0.1“phonegap-plugin-local-notification”并使用以下代码对其进行测试(在设备就绪状态下):

        if ("Notification" in window) {
        Notification.requestPermission(function (permission) {
            // If the user accepts, let's create a notification
            if (permission === 'granted') {
                var notification = new Notification("My title", {
                    tag: 'message1',
                    body: "My body"
                });
                notification.onshow  = function() { console.log('show'); };
                notification.onclose = function() { console.log('close'); };
                notification.onclick = function() { console.log('click'); };
            }
        });
    }

我得到的是通知不在窗口。有谁知道如何使用这个插件或我应该添加任何东西到config.xml。

或者是否有任何其他解决方案来发送本地通知

cordova phonegap-plugins cordova-plugins phonegap phonegap-pushplugin
2个回答
0
投票

我使用了以下插件:https://github.com/katzer/cordova-plugin-local-notifications

虽然我通过Phonegap应用程序测试了插件但它没有工作但是在构建android apk之后它工作得很好。


0
投票

尝试使用这个插件。适用于android和Ios。

<plugin spec=" https://github.com/acianti/cordova-plugin-local-notifications.git" />
© www.soinside.com 2019 - 2024. All rights reserved.