Open jakub-g opened 8 years ago
So depending on the payload in node-gcm, the plugin behaves differently.
Sometimes, the phonegap-plugin-push#onNotification
is called just fine, but sometimes it is not called.
Accidentally, since I'm also using a webintent plugin, registered as window.plugins.webintent.onNewIntent(__myHandleWebIntentCb);
, I've noticed in the cases where phonegap-plugin-push#onNotification
is not called, the webintent's callback is called instead, which may shed some light on the underlying issue.
Though I think, the presence of webintent plugin is not the reason of the bug. When I remove the webintent plugin from the app, no callback is still called,
So here are the different cases:
1a) [onNotification] is called
var message = new gcm.Message();
message.addData({
customField: 'my custom field',
alert: 'ALERT'
});
1b) [onNotification] is called
var message = new gcm.Message({
notification: {}
});
message.addData({
customField: 'my custom field',
alert: 'ALERT'
});
2) [onNotification] NOT CALLED, instead __myHandleWebIntentCb is called!
var message = new gcm.Message({
notification: {
icon: 'push_notification_icon',
color: 'blue'
}
});
message.addData({
customField: 'my custom field',
alert: 'ALERT'
});
3) [onNotification] NOT CALLED, instead __myHandleWebIntentCb is called!
var message = new gcm.Message({
notification: {
title: "TITLE",
body: "BODY"
}
});
message.addData({
customField: 'my custom field',
alert: 'ALERT'
});
And here's how different cases look in the UI:
I originally tested with 1.5.3 but the behavior is identical in 1.6.0
You can also see in one of the cases the icon is not displayed, I opened #747 for that
@jakub-g Yeah, the problem is when you add the notification
property to the gcm.Message
object with a title
and body
the OS takes over. Once the OS takes over the plugin never gets called. It's on my list to look into but for now I suggest not populating the notification
object. That's why all of my sample node-gcm scripts use the data
object only.
Hello, i noticed when i avoid to set notification (as said before), the phone receives the push, but it comes empty (no title, no body, no sound) on the notification drawer. The title, body and sound are defined on the data object.
The strange behavior is that it works for the first message that arrives on the message bar (it comes with title, body and sound), but the others come empty.
Any idea how to solve it?
Expected Behaviour
The
onNotification
callback should be fired when user clicks the notif in notification drawer, regardless if the app was not in foreground / background / not runningActual Behaviour
When the app is in background when user clicks the notif, or the app was started from user clicking the notification, the callback may not get called, depending on the notif payload
Reproduce Scenario (including but not limited to)
Platform and Version
Android 5.1
(Android) What device vendor
Motorola MotoG3
Cordova CLI version and cordova platform version
Plugin version
Sample Code that illustrates the problem
Sample Push Data Payload
Will post separate cases in the next message