I'm using firebase-admin on nodejs to send push notifications to users: https://firebase.google.com/docs/admin/setup
I'm using firebase_messaging on flutter: https://pub.dev/packages/firebase_messaging
I'm trying to send a push notification with the highest priority on both android and ios.
firebase.messaging(firebaseApp).send({
token,
notification,
android: { priority: 'high' },
apns: { headers: { 'apns-priority': '10' }, payload: { aps: { sound: 'default' } } },
data
}
On my development devices it works like a charm both when the app is in the background and when it's terminated.
I'm receiving push notifications that visibly pop and make a sound 100% of the time, on both android and ios.
The issue is on other devices -
If the app is in the background, I can sometimes see an actual push notification visibly pop, and make a sound as it should. Sometimes not.
If the app is terminated, a push notification is received - but it doesn't visibly pop nor make a sound, I can only see it if I scroll down the menu from the top of the screen, it's listed as a received push notification. Sometimes the notification is not receieved at all.
I tried to change the priority of notifications from my app to high on the actual device as well, but it didn't change anything.
My users keep complaining that they're not receiving push notifications - I'm guessing they either actually don't receieve them or simply don't see them since they're recieved silently as I described above.
I literally have no idea what's going on and why it doesn't work as it should on devices other than my own development devices.
Any ideas?
In the main app target, select Signing & Capabilities > All > + Capability and then search "push." Double-click on Push Notifications to enable it. Next, enable Background Modes and check Remote Notifications. Now you are ready to send notifications from the OneSignal dashboard!
Users can choose to mute their notifications and receive silent push notifications instead of being alerted to every new push that arrives. They can activate this on iOS or Android from their individual settings pages. And developers or mobile marketers cannot override this setting once put into place.
Using FCM Console To send a notification, go to Firebase Console → Cloud Messaging and click on Send your first message. Then enter the Title and body field. If you wish to send it to a particular device then click on Send test message and enter the FCM registration token. (Enter the current FCM registration token).
There are two tags that need to be intact when we are sending push from firebase api
If android 7.0 or 8.0 above device do not receive the android_channel_id than it will not show notification and so always set default notification channel in the android manifest. we can check available tags in json request we are setting via node. from here
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id"/>
like this and make sure you create the notification channel at mobile end.
String CHANNEL_ID = "your_channel id";
String CHANNEL_DESCRIPTION = "Your description to show in settings";
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_DESCRIPTION, NotificationManager.IMPORTANCE_HIGH);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
If you see the flutter app logs it will show you some error like default channel not set in manifest or no channel found in notification.
make sure you put logs in your question to resolve this or contact me to resolve the issue.
Also make sure you read Optionally handle background messages section from here fcm flutter lib there they mentioned adding fcm in android folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With