问题
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 notification while application is on i got vibration and the message is showing inside the cards div as mentioned in index.js but i got no notification on status bar , if the application is on background i got also no notification on status bar but i got vibration. i wonder why i have no notification popup on status bar. i use phonegap-plugin-push 1.4.4
回答1:
@Del
i am using ruby to send a notification
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)
回答2:
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
});
}
}
来源:https://stackoverflow.com/questions/34065875/push-notification-doesnt-show-up-on-status-bar