Firebase API is not sending push notifications when using the API
I got contacted by Firebase support and was able to find out what is wrong
My push payload was missing a notification object
{
"to": "<registration token>",
"priority": "high",
"notification": {
"title": "Your Title",
"text": "Your Text"
}
"data": {
"customId": "<my custom id>",
"badge": 1,
"sound": "cheering.caf",
"alert": "New data is available"
}
}
I hope that helps someone else
Firebase Push Notification not working with API 28
Create a channel and set the importance
Before you can deliver the notification on Android 8.0 and higher, you
must register your app's notification channel with the system by
passing an instance of NotificationChannel to
createNotificationChannel().
As the documentation say, you need to add a notification channel in android 8 and higher so the system shows your notification.
private void createNotificationChannel() {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = getString(R.string.channel_name);
String description = getString(R.string.channel_description);
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
channel.setDescription(description);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
}
Can't send push notifications using the server API
On iOS the priority
field seems mandatory.
{
"to": "cHPpZ_s14EA:APA91bG56znW...",
"priority": "high",
"notification" : {
"body" : "hello!",
"title": "afruz",
"sound": "default"
}
}
Failed to send the FCM push notification using the REST API
There's a Line Feed (LF)
character in your URL (%0A after URL encoding) which is not valid API URL. That may have been added while copying from the documentation or other source.
The URL should be /fcm/send
instead of /fcm/send%0A
.
Firebase push notification delivery report
In my case that was because of overriding handleIntent
function in FirebaseMessagingService
. So with removing this function from service the problem fixed.
Firebase Cloud Messaging - PHP Rest API not working for iOS
Android and iOS handle Push Notifications differently. While Android will only wake from background when only the data
tag is provided, iOS devices require the notification
tag to deal with notifications received while the app is in the background.
Related Topics
Fonts Not Displaying in Interface Builder
Apple Watch - Only Getting Data If App on Phone Is Active
How to Change a Swiftui Color to Uicolor
Finding Distance Between Cllocationcoordinate2D Points
How to Add Custom Text in Nsdateformatter's Format String
Facebook App Requests Aren't Shown on iOS Devices
Xcode Duplicate Symbols for Architecture Error After Updating Cocoa Pods
Detect When a Unicode Character Cannot Be Displayed Correctly
Remote Image Size Without Downloading
Programmatically Highlight Uibarbuttonitem
Simple Uitableview in Swift - Unexpectedly Found Nil
Enable Uialertaction of Uialertcontroller Only After Input Is Validated
iOS 7 When Rotating View in Tab Bar, Right Side of View Is Not Clickable
Static VS Class as Class Variable/Method (Swift)