推送通知未显示在状态栏上

时间:2015-12-03 12:17:02

标签: android cordova phonegap-plugins phonegap-build phonegap-pushplugin

我正在使用带有phonegap-plugin-push的phonegap,我尝试了插件附带的示例,我在手机上测试了它(Galaxy s4,Android 5.0.1),当我在应用程序打开时发送通知我得到了振动,消息显示在index.js中提到的卡片内,但我没有通知状态栏,如果应用程序在后台我也没有通知状态栏但我有振动。我想知道为什么我的状态栏上没有通知弹出窗口。 我使用phonegap-plugin-push 1.4.4

2 个答案:

答案 0 :(得分:1)

@Del

我正在使用ruby发送通知

require 'rubygems'
require 'pushmeup'

GCM.host = 'https://android.googleapis.com/gcm/send'
GCM.format = :json
GCM.key = "key"
destination = ["id"]
data = {:title => "PhoneGap Push",:message => "PhoneGap Build rocks!",         :msgcnt => "1", :soundname => "beep.wav"}
options = {:collapse_key => "placar_score_global", :time_to_live => 3600, :delay_while_idle => false}

GCM.send_notification( destination, data, options)

答案 1 :(得分:0)

当您收到推送通知时,您还需要在此时提出本地通知,该通知将显示在状态栏和通知栏中。我是phonegap-plugin-localNotifications插件的粉丝,您可以在https://github.com/Wizcorp/phonegap-plugin-localNotifications找到它。因此,在Android的phonegap-plugin-push onNotification处理程序中,您可以执行以下操作:

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