push notification doesn't show up on status bar

前端 未结 2 1520
温柔的废话
温柔的废话 2021-01-23 01:09

i\'m using phonegap with phonegap-plugin-push , and i tried the example that comes with the plugin , i tested it on my phone ( Galaxy s4 , Android 5.0.1 ) , when i send notifica

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-23 01:30

    When you receive the push notification you will also want to raise a local notification at that point which will appear in your status bar and notification tray. I'm a fan of the phonegap-plugin-localNotifications plugin for doing this, you can find it at https://github.com/Wizcorp/phonegap-plugin-localNotifications. So in your phonegap-plugin-push onNotification handler for Android you would do something like this:

    onNotification: function (e) {
        if (e.event == "message") {
            localNotification.add(1, {
                message: e.payload.message,
                badge: 1
            });
        }
    }
    

提交回复
热议问题