- Notification icon is not showing in android 8.0 and and above #1796
- Comments
- ghost commented Dec 27, 2018
- eladglobalbit commented Dec 27, 2018 •
- ghost commented Dec 31, 2018
- eladglobalbit commented Jan 1, 2019
- iadcg commented Jan 17, 2019
- stale bot commented Feb 14, 2019
- fachrihawari commented Feb 20, 2019 •
- charliejeppsson commented Feb 25, 2019
- fachrihawari commented Feb 26, 2019
- LaVielle commented Mar 21, 2019 •
- stale bot commented Apr 18, 2019
- stale bot commented May 6, 2019
- perlics commented Oct 23, 2019
- IamWinWon commented May 25, 2020
- LPitonakova commented Jun 9, 2020 •
- sumitrahate commented Jun 19, 2020
- mikehardy commented Jun 19, 2020
- Changing the firebase notification icon in Flutter.
- Hands-on with Material Components for Android: Buttons
- Part 4 of a series covering practical usage of Material Components for Android
- Setting up a Material Components theme for Android
- Attribute by attribute
- Basic usage 🏁
- Choosing a style 🤔
- Adding an icon 🔷
- Grouping Buttons to create a Toggle Button 👨👩👧👦
- Grouping
- Adjusting selected behavior
- Listening for selection state
- Orientation
- Theming 🎨
- Color
- Typography
- Shape
- More resources 📚
Notification icon is not showing in android 8.0 and and above #1796
Comments
ghost commented Dec 27, 2018
Hi,
I am using ‘react-native-firebase’ for FCM. Android version below 8.0 the push notification icon is working fine, but android version 8.0 and above the empty push notification icon is displaying.
Can u guys please help me to fix this issue.
The text was updated successfully, but these errors were encountered:
eladglobalbit commented Dec 27, 2018 •
do u can post your Android Manifest.xml?
I think the problem is there and u not set value for your chanel
ghost commented Dec 31, 2018
Hi,
Here is my AndroidMainfest.xml
eladglobalbit commented Jan 1, 2019
#1781 u can see my and compare 🙂
iadcg commented Jan 17, 2019
@BabuAjith Hey bro. How is it going in your side now? Have you found the cause and fixed it?
stale bot commented Feb 14, 2019
Hello 👋 , this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community’s attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
fachrihawari commented Feb 20, 2019 •
@iadcg @BabuAjith hey guys, i got same problem. Are you have a solution ?
charliejeppsson commented Feb 25, 2019
@fachrihawari also tried reusing @mipmap/ic_launcher for the notification icon unsuccessfully. The solution was to instead use https://romannurik.github.io/AndroidAssetStudio/icons-notification.html to generate separate notification icon files and then adding each to the android/app/src/main/res/mipmap-hdpi, mipmap-mdpi etc directories
fachrihawari commented Feb 26, 2019
@charliejeppsson for android > v7.0 icon must be transparent. Before I use non transparent icon, and solved after change to transparent icon
LaVielle commented Mar 21, 2019 •
I have to create transparent icons (basically a white silhouette of the logo on the normal icon, with a transparent background). I called those icons ic_stat_ic_notification.png and placed them in the mipmap folders.
Then I added these lines to AndroidManifest.xml :
The first is to set the default notification icon
The second is to set the background color of the circle surrounding the icon
stale bot commented Apr 18, 2019
Hello 👋 , this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community’s attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
stale bot commented May 6, 2019
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.
perlics commented Oct 23, 2019
You probably need a transparent notification icon. What I think happens is you have a background and Android colors your icon depending on the theme. Just make it transparent and it will be ok.
IamWinWon commented May 25, 2020
My problem was MIUI os. it is their bug.
LPitonakova commented Jun 9, 2020 •
So I’ve been using the wix react-native-notifications library to display my notifications. Turns out they chose to write custom code to completely override whatever you set in your metadata!
I discovered this by searching for Notification.Builder in the whole project. There is a piece of code that looks explicitly for a file in drawable/ called notification_icon .
So the solution is to create 1 icon which is transparent + white color and put it in as drawable/notification_icon.png
I can’t believe somebody would write a confusing piece of code like this but that’s the horrors of open source for you :/
sumitrahate commented Jun 19, 2020
can any body help me , i am having the same issue notification icon showing in gray background, i have added transparent background icon but still not fix for me
mikehardy commented Jun 19, 2020
@sumitrahate no one will be able to help I am afraid, it will be a project-specific issue. You can create a super-tiny throwaway react-native app and just using snippets from StackOverflow have it throw up a notification to replicate and poke around until you get the icon references correct etc.
Источник
Changing the firebase notification icon in Flutter.
Adding custom icons to some or all of your notifications. Icons are a way to provide a more unique, branded experience for your app.
Let’s see how we can change the notification icon when the app is in background and notification received.
- Setting a custom default icon allows you to specify what icon is used for notification messages if no icon is set in the notification payload. Also, use the custom default icon to set the icon used by notification messages sent from the Firebase console.
- Let’s start: first Add icon inside the drawable folder for notification icon.
Note: The notification icon which you want to add should be transparent. If the transparent icon is not added, then by default grey icon is getting display even you followed all steps properly.
3. The folder structure is shown below:
(flutter_app_name > android > app > src > main > res >drawable > notification_icon.png)
4. When no icons are set for incoming notifications, firebase will take the default icon and shows a notification.
5. To override the default icon add below code into your Android manifest file.
Also, you can provide color for the icon.
6. For color, we have to add that color in colors.xml file inside the values folder, so create a file inside the values folder.
The file path should be:
app > src > main > res > values > colors.xml
so, for adding color to notification icon we have to add color in color.xml file which we have added in values folder.
7. Add your image with a transparent background.
Disadvantage: If you upload a colored version, you will get a dark grey icon, which would look nasty. If you don’t have a white version of your logo, get it designed.
In this way, you can change the notification icon with the color you want.
Источник
Hands-on with Material Components for Android: Buttons
Part 4 of a series covering practical usage of Material Components for Android
This post will be covering the features and API of Button components. To find out how to handle initial setup of Material Components for Android (including the Gradle dependency and creating an app theme), please see my original post:
Setting up a Material Components theme for Android
Attribute by attribute
Buttons are arguably the most widely-used components in any app. This is largely due to their versatility, allowing users to perform actions and make choices that ultimately guide the flow of an experience. A single line of contained text and/or an icon indicate the action a button can perform.
Material Buttons are slightly different to traditional Android buttons in that they do not include additional insets (4dp on the left/right) and have more letter-spacing, different default colors and other attributes that improve legibility and affordance amongst other components.
From a design perspective, there are three main types of buttons which are intended to offer hierarchical levels of emphasis:
- Text button (low emphasis): No container. Best used for less important actions, especially when other main content needs to be emphasised.
In addition to this, buttons can be grouped together into a fourth type: Toggle button. This allows related button actions to be horizontally arranged in a common container. The buttons themselves can be selected/deselected to indicate an active/inactive choice.
Basic usage 🏁
A MaterialButton can be included in your layout like so:
Choosing a style 🤔
As discussed in the intro section above, a variety of button types exist. These types map to styles that you can apply to a MaterialButton . There also exists a variety of sub-styles for specific use cases, such as to adjust padding for an icon. The full list of styles and their attributes can be found on GitHub. These style variants inherit from Widget.MaterialComponents.Button , each with an optional style suffix:
- Text button: *.TextButton (main), *.TextButton.Icon , *.TextButton.Snackbar , *.TextButton.Dialog , *.TextButton.Dialog.Icon , *.TextButton.Dialog.Flush
- Outlined button: *.OutlinedButton (main), *.OutlinedButton.Icon
- Contained button (unelevated): *.UnelevatedButton (main), *.UnelevatedButton.Icon
- Contained button (raised): No suffix (default, main), *.Icon
Adding an icon 🔷
An icon can be added to a button. It is displayed at the start, before the text label. In order to get the correct icon padding, it is recommended that you use a *.Icon style variant (shown above in the “Choosing a style” section).
The icon can be added in XML:
Alternatively, it can be done programmatically:
A few additional attributes exist for adjusting the icon size and position:
- iconSize : The width/height of the icon. The default value is the supplied Drawable ’s intrinsic width.
- iconGravity : The gravity of the icon. This can be set to start ( ICON_GRAVITY_START , default, at start of button), end ( ICON_GRAVITY_END , at end of button), textStart ( ICON_GRAVITY_TEXT_START , at start of centered text label) or textEnd ( ICON_GRAVITY_TEXT_END , at end of centered text label).
- iconPadding : The spacing between the icon and the text label. Typically you would not want to change this. The default value is 4dp for text buttons and 8dp for all other types.
Attributes related to icon tinting are discussed in the “Theming” section below.
Grouping Buttons to create a Toggle Button 👨👩👧👦
In order to create a toggle button, we need to add MaterialButton s as child View s to a MaterialButtonToggleGroup (a custom ViewGroup ).
Note: MaterialButtonToggleGroup was added in the 1.1.0-alpha05 release of Material Components for Android.
Grouping
This can be done in XML:
Alternatively, it can be done programmatically:
The MaterialButtonToggleGroup handles layout and adjusting of only the relevant shape corners in the row of MaterialButton s. The appearance of the MaterialButton s is determined by whichever style they each use. It is advised to use a consistent style for all children and also recommended to use the outlined button type.
Adjusting selected behavior
When added to a MaterialButtonToggleGroup , child MaterialButton s automatically become “selectable” (i.e. The android:checkable attribute is set to true).
Thus, there exists a couple of attributes for adjusting how MaterialButtonToggleGroup manages this:
- singleSelection : Determines whether or not only a single button in the group can be checked at a time. The default value is false, meaning multiple buttons can be checked/unchecked independently.
Listening for selection state
We are able to query for and adjust the current checked button(s) in a variety of ways:
We are also able to listen for checked changes by adding an OnButtonCheckedListener to a MaterialButtonToggleGroup :
Listeners can also be removed with the MaterialButtonToggleGroup#removeListener and MaterialButtonToggleGroup#clearListeners functions.
Orientation
The default arrangement of buttons within a toggle group is horizontal. However, seeing as MaterialButtonToggleGroup extends LinearLayout , it also supports vertical arrangement. This can be set programmatically or in XML:
The interesting thing to note here is the extra attributes on the child MaterialButton (s). It is recommended to set the width to match_parent and to remove the top/bottom insets from the child buttons so as to have them sit flush against each other vertically. This also, however, requires adjusting the minHeight to make up for the lack of insets.
Theming 🎨
Buttons can be themed in terms of the three Material Theming subsystems: color, typography and shape. We have already shown which styles to use in the “Choosing a style” section above. When implementing a global custom MaterialButton and MaterialButtonToggleGroup styles, reference them in your app theme with the materialButtonStyle / materialButtonOutlinedStyle and materialButtonToggleGroupStyle attributes respectively.
Color
The color of the MaterialButton background can be customized with the backgroundTint attribute. This requires a ColorStateList , meaning a for checked/enabled/disabled states is required. It defaults to colorPrimary (enabled)/ colorOnSurface (disabled) for contained buttons and transparent(unchecked)/ colorPrimary (checked) for all other types, with different opacities per state. There is also a backgroundTintMode attribute to change the tint PorterDuff.Mode , although typically you would want to keep this the same.
The color of the text label can be customized with the android:textColor attribute. This too requires a ColorStateList . It defaults to colorOnPrimary (enabled)/ colorOnSurface (disabled) for contained buttons and colorPrimary (enabled or checked)/ colorOnSurface (disabled or unchecked) for all other types, with different opacities per state.
The color of the optional icon can be customized with the iconTint attribute. This too requires a ColorStateList and the defaults are the same as those of android:textColor . As before, there is also an iconTintMode attribute.
Lastly, the color of the button touch ripple can be customized with the rippleColor attribute. It too accepts a ColorStateList and defaults to colorOnPrimary for contained buttons and colorPrimary for all other types, with different opacities per state.
Typography
The button text label will adopt the fontFamily attribute defined in your app theme.
While you would typically want to keep most aspects of the button text appearance as is, the Material Guidelines suggest we can use sentence case over the standard all caps for the text label, if desired. To achieve this, we would create a new style:
We could apply this directly to a button or in an individual button style by referencing it with the android:textAppearance attribute. Alternatively, it can be applied globally by referencing it in your app theme with the textAppearanceButton attribute.
Shape
The shape of a button background can be customized with the shapeAppearance attribute. This defaults to shapeAppearanceSmallComponent .
While not strictly shape theming, it is worth mentioning that the width of an outlined button stroke can be adjusted with the strokeWidth attribute. This defaults to 1dp.
More resources 📚
- The source code for the Playground app used in this article can be found on GitHub.
- Buttons Design Documentation
- Buttons API Documentation
- Toggle Buttons API Documentation
I hope this post has provided some insight into Material Buttons and how they can be used in your Android app(s). If you have any questions, thoughts or suggestions then I’d love to hear from you!
Источник