Why Firebase push notification work only when App is closed - firebase

I don't receive any notification when my application is open. Is this normal? I just receive push notifications when my app is closed.
My service is:
<service
android:name=".FirebaseNotificationService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>

This is working as intended. Messages received when in foreground will be handled in onMessageReceived(). Similar post answered here.

Related

Android 12 firebase push notifications don't work when app is in the background

I'm sending test push notifications form firebase>compose notification page. I receive push notifications on Android 8, 9, 10, 11, but not 12.
And I have two devices on Android 12: physical phone Samsung S22 and Pixel emulator. In both cases Push Notifications don't appear in the Notification tray.
Note:
I'm speaking about notification which system shows in the Notification tray while app is being in the background. When app is in the foreground, then onMessageReceived works as expected on Android 12.
token is correct
in all cases I close the app in order to get Push in Notification tray
if I use android:exported="false" - still doesn't work
My service in the android manifest:
<service
android:name=".old.push.FCMHandlerService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
In my case i was using an old version of react native firebase and i made the changes for the pending Intent. However the error appear by using an old dependency in my build.gradle inside the app folder which hadn't solved the pending intent change. I just upgraded the versions of "com.google.firebase:firebase-messaging:xxx for the following
implementation "com.google.firebase:firebase-iid:21.1.0"
implementation "com.google.firebase:firebase-messaging:22.0.0"
For more infor check this issue:
https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/1876

Cannot target Android Channel from Azure Notifcation Hub

We are using Azure Notification Hub to send push notifcations to iOS and Android devices.
To ensure by that default our notifcations are displayed with an on screen popup on Android we have created a custom Channel with an id of "Default"
Using the Firebase Compose test Message UI I can send a PN and tag it with the "Default" channel. However I cannot mange to target the channel from an Azure Hub Notification. I am assuming that the JSON I am sending along with the tags and the token to NotificationHubClient.SendFcmNativeNotificationAsync is wrong
What is the correct JSON for sending a message that targets a channel?
UPDATE - WORKAROUND
Whilst I am still unable to get the Channel to be set I have found the setting in Android that says "If no channel is set use this Channel Id". It is com.google.firebase.messaging.default_notification_channel_id
<application android:label="Breathe RM" android:icon="#mipmap/app_icon" Name="Breathe RM" tools:replace="android:label">
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="Default" />
</application>
This is enough for now as we only have a single channel

Firebase Push Notifications not working on Android 8 and above when app is closed

Am working with Flutter and I have been looking for a fix for this for a while. At first I thought the notifications are not been received when the app is closed, but it worked on my Android 5 device.
I have added this in my Android Manifest file already
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
On the Android 8 and 9 devices i have with me, when I send any push notification from Firebase, i receive the notifications only when the app is running or if i minimize the app. But when the app is completely closed, i don't get the notification at all. Please a fix for this will be highly appreciated as it is the last feature i intend including before release.
My intention is actually sending notifications to all users. I have tried using Flutter Local Notification package too but i receive it on only one device.

Flutter FCM on iOS not calling onMessage and onResume

I was testing FCM for flutter on an iOS device, i followed the guides and i can successfully send notification to my iOS device, the problem is that when i touch the notification neither onResume is not being called, also if the app is in foreground onMessage is not called either. However if the app is closed it does trigger onLaunch
I wonder how can i fix this? or if anyone else is having this problem?
The problem was that i was using another plugin for handling local notifications(flutter_local_notifications) and it was causing conflict with firebase messaging(the plugin says that in the Readme file), so i removed flutter_local_notifications and firebase messaging started to work as intended
Did you try setting:
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
in ios/Runner/info.plist?

willpresentnotification method not called

At first glance, this may look similar to many other questions on stack overflow, but I didn't find the solution for the issue I am facing. I am using xcode 8.3.2 and ios 10.3.2 and configured FCM to send push notifications. I am receiving push notifications in foreground, background and not running states so no problem from firebase end or certificates. I have set the delegate for UNUserNotificationCenter and FIRMessaging as well. I am testing the service by sending notification from firebase console. When I press the notification to launch the app, the method userNotificationCenter didReceive response method is getting called, but when the app is in foreground userNotificationCenter willPresent notification is not getting called when a notification arrives. I have tried enabling and disabling method swizzling as well. didn't help.

Resources