How To Make A Compact Notification With FCM (Firebase Cloud Messaging)?
Since FCM does not let me send a URL type "icon", I was trying to apply local notifications as soon as messages arrived by FCM of type "data". But messages of type "data" are not handled when the application is closed, so I had to reuse those of type "notification". Since the "icon" option does not work with URLs I was thinking of using "image", but I only need the small one that acts as an icon. Is there any way to compact the message so that it hides the large image and only shows the small one?
It would be something like the second message in the image below, this hidden big image to receive another message.
The JSON structure of the notification in REST is as follows:
{
"to": "fVJq6D9...................................",
"notification": {
"title": "Title Message 2",
"body": "Body Message 2",
"image": "http://www.iconarchive.com/download/i65798/hopstarter/bioman/Bioman-Avatar-1-Red.ico"
}
}
For the construction of the App I am using Flutter.
Answer
Currently this is not possible as the icon you want to set dynamically is the small icon set by setSmallIcon()
which requires id to a locally stored resource as from it's definition:
/**
* Set the small icon to use in the notification layouts. Different classes of devices
* may return different sizes. See the UX guidelines for more information on how to
* design these icons.
*
* @param icon A resource ID in the application's package of the drawable to use.
*/
public Builder setSmallIcon(int icon) {
mNotification.icon = icon;
return this;
}
You cannot get the id the an image fetched by server. Instead, you can try to create different notifications depending upon cases with corresponding small icons set in the code.
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View