Open 3rror404 opened 6 years ago
I am having the same issue on iOS. Able to receive notifications normally when the app is in foreground, background and when suspended. But the two later states do not hit the onMessageReceivedCallback
.
I have noticed that it has something to do with the notification-payload itself. It depends if you send a generic, hybrid or custom payload.
Generic-payload (used by the FCM console).
It only contains the notification
payload, and not the data payload. On iOS it works on all states, but hits the callback only when the app is in foreground.
{
"to" : "TOKEN_FCM",
"notification" : {
"body" : "First Notification",
"title": "Collapsing A"
}
}
Hybrid-payload (used by the FCM console).
Contains both the notification
and data
payload. On iOS it works on all states, but hits the callback only when the app is in foreground.
{
"to" : "TOKEN_FCM",
"notification" : {
"body" : "First Notification",
"title": "Collapsing A"
},
"data" : {
"body" : "First Notification",
"title": "Collapsing A",
"data_id" : "30515",
"data_type" : "article"
}
}
Custom-payload (used by custom apps that use the FCM API, e.g. Postman).
Contains only the data
and not the notification
payload. On iOS it hits the callback and returns the payload on all states. But does not show built-in banners/notifications because it is dependent on the notification
payload. You receive the payload when one starts the app.
{
"to" : "TOKEN_FCM",
"data" : {
"body" : "First Notification",
"title": "Collapsing A",
"data_id" : "30515",
"data_type" : "article"
}
}
I've not tested this on Android yet.
It is very useless this way. Data-Notifications should be process even if the app is in background. It seems that the plugin does not support this? @EddyVerbruggen is this right?
Desired way to process push notifications when data message arrives (app is in background): The callback is triggered and the app can evaluate the incoming message and do some action - show a notification in the system tray with the plugin "local notifications" for example..
BR, Lacos
My situation is similar to the one observed by @3rror404 under iOS, but different with that if the app is terminated and I tap on received push notification the onMessageReceivedCallback() is called. If the app is only in background it receives all messages as it is in foreground. If you try to resume the app by taping a push notification it doesn't call the onMessageReceivedCallback().
In my case I want to navigate to a certain page after the app is opened/resumed through a push notification.
@bozhidarc Did you ever solve this?
@bozhidarc Did you ever solve this?
Sorry, but I have no recent experience with this functionality.
I'm having some problems getting notifications to work as I would like.
I'm using the following commands to test notifications:
Text and data notification:
Data only notification:
Desired behaviour:
onMessageReceivedCallback
will be called when either notification type is received.onMessageReceivedCallback
will be called when the app is opened.Actual behaviour:
iOS text-and-data:
onMessageReceivedCallback
is called and I am able to access any data attached to the notification (✔︎).onMessageReceivedCallback
is not called (✖️).iOS data-only:
onMessageReceivedCallback
is called immediately (✔︎).onMessageReceivedCallback
is called when the app is opened and I am able to access any data attached to the notification (✔︎).Android text-and-data:
onMessageReceivedCallback
is called and I am able to access any data attached to the notification (✔︎).onMessageReceivedCallback
is called but I am not able to access any data attached to the notification (✖️).Android data-only;
onMessageReceivedCallback
is called immediately (✔︎).onMessageReceivedCallback
is called immediately (✖️ - but i can live with this behaviour).onMessageReceivedCallback
is not called when the app is opened (✖️).I have a basic view-model that holds the
init()
code:I call
doInit()
fromapp.js
. I've tried initialising in the first view rather thanapp.js
but that doesn't seem to help.Could anyone help me to achieve the desired behaviour?