Open iampeternguyen opened 4 years ago
Use local notification plugin for android only
same problem
Hey there, I am facing the same issue cuz I implemented and extended the FirebaseMessagingService, which I think somehow blocked the thread executing the callback. So maybe you guys can try to find is there any other package implementing the mentioned service like I did. And for now, I am still trying to find the way to implement my own service and make the original service work. One more interesting thing is, I believe the class is not being overridden, cuz when the app is in the background / or closed, the notification from firebase can smoothly arrive. :p
ps: The smoothly arrive which I mean is, I can see the message coming from firebase in the onMessageReceived callback.
same problem
Use local notification plugin for android only
@ArigarasuthanRepo can you elaborate on that?
Use nativescript-local-notifications
And in the callback of nativescript-firebase-plugin's push notification, just create a local notification with forceShowWhenInForeground
set to true
private messageReceivedCallback(data) {
if (isAndroid) {
LocalNotifications.schedule([
{
title: "Your title",
body: data.data.message,
thumbnail: false,
forceShowWhenInForeground: true
}
]);
}
}
Are there any reasons why push notifications might not show up when the app is in the foreground?
I setup a basic app with the code below. I can get push notifications when I close and kill the app, but when in the foreground I don't get the notification. It does get logged in my console both in the foreground and background though.
from postman
in my console log (foreground) JS: ==== object dump start ==== JS: foreground: "true" JS: from: "198270081665" JS: title: "My title" JS: body: "My text" JS: data: { JS: "foo": "bar" JS: } JS: ==== object dump end ====
in my console log (background) - notification received JS: ==== object dump start ==== JS: foreground: "false" JS: data: { JS: "google.delivered_priority": "high", JS: "google.sent_time": {}, JS: "google.ttl": {}, JS: "google.original_priority": "high", JS: "foo": "bar", JS: "google.message_id": "0:1588254508121424%8014bbaa8014bbaa" JS: } JS: google.delivered_priority: "high" JS: google.sent_time: 1588254508106 JS: google.ttl: 2419200 JS: google.original_priority: "high" JS: foo: "bar" JS: google.message_id: "0:1588254508121424%8014bbaa8014bbaa"