Hi all, I have an app which I have configured with firebase push notifications, when I send a message and the app is in the background I see a physical notification pop up, but when the app is in the foreground, I don't see the notification, is it possible to display an actual notification while the app is in the foreground, I could have sworn i have done this before, or I may have been dreaming, any advice?
You can use the new UserNotificationCenter to create a local notification from Application_RemoteNotification: UserNotificationCenter class
Such notifications will appear even when the app is in the foreground.
You can use the new UserNotificationCenter to create a local notification from Application_RemoteNotification: UserNotificationCenter class
Such notifications will appear even when the app is in the foreground.
You can use the new UserNotificationCenter to create a local notification from Application_RemoteNotification: UserNotificationCenter class
Such notifications will appear even when the app is in the foreground.
I've tried it and it seems to work, I can now see the Notification even when the app is in the foreground, at first everything was working just great, the
Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler) Sub was being raised all the time, I didn't make any other changes than the ones you suggested above, now I can send a push notification and it is being received but the Sub Application_RemoteNotification Sub is not being raised anymore, any ideas what may be going on?
I decided to run some test and took out the UserNotificationCenter part out, now I can see the Application_RemoteNotification sub being raised.
So I decided to Initialize the UserNotificationCenter class once inside the Application_RemoteNotification sub, and the first time I launch the app I can see the Notification etc..
But all the consecutive app launches I start seeing the same issue again where the Application_RemoteNotfication is no longer being raised, I think the UserNotificationCenter class is causing this issue for sure, now the question is, How can I get the app to raise the Application_RemoteNotification every time even after Initializing the UserNotificationCenter class, This is specially important for me as there's some other code that needs to run inside the Application_RemoteNotification sub.
Yes, If I continue sending more notifications after the first one, then the Application_RemoteNotification Sub does not get raised anymore.
I will try to upload a small project.
I've created a small project, and I see the same behavior, just to recap, the first time the app is launched the Application_RemoteNotification sub is raised and the localnotification pops up after 4 seconds, after this if i send a new Push notification, the firebase push notification is recieved but the Application_RemoteNotification Sub is not raised anymore, you can see this behavior on this example I created.
You are correct, however the behavior is actually better.
The push message is displayed even when your app is in the foreground. This is what you wanted, right? You don't need Application_RemoteNotification at all.
You are correct, however the behavior is actually better.
The push message is displayed even when your app is in the foreground. This is what you wanted, right? You don't need Application_RemoteNotification at all.
In my case I actually need the Application_RemoteNotification because there's some code that gets executed from inside this sub, for example saving the message's content inside a database and displaying those messages on a list view later on.
Sounds like a mistake. You will lose:
- messages that arrive while the app is in the background.
- messages that are missed because of network problems.
I assume that most of the time your app is not in the foreground so most messages will be lost.
The correct solution is to check for the data with your server, once the app is started.
Only use push notifications to notify the user while the app is in the background.