I’ve a server that sends push notifications. For Android, I override onMessageReceived
to deal with the message. For iOS, I exploit NotificationExtension
. I want to vary the incoming push notification. What’s odd is that I can’t discover a option to make it work for each platforms. Here is the factor:
- For Android, the payload of the push notification should NOT comprise a
notification
block. If there’s anotification
block current, the title and physique of thenotification
shall be proven when the app is within the background and theonMessageReceived
isn’t referred to as. This isn’t desired. Eradicating thenotification
block and simply holdinformation
works for Android for each background and foreground mode. - After I omit the
notification
block for iOS, I get an error again from Firebase:InvalidParameters: Invalid notification payload
.
Examples
Payload with out notification
(works totally for Android on background + foreground mode, fails to ship (and thus retrieve) for iOS):
{
"to" : "-",
"information" : {
"physique" : "Notification Physique",
"title": "Notification Title",
},
"mutable_content": true
}
Payload with notification
, this works totally for iOS however doesn’t name the onMessageReceived
methodology on Android when the app is within the background:
{
"to" : "-",
"information" : {
"physique" : "Notification Physique",
"title": "Notification Title",
},
"mutable_content": true,
"notification": { "title": "take a look at" }
}
How can I make each platforms work on foreground + background information push messages?