How do I change the color of the push notification icon in flutter? [duplicate] - dart

I tried making the small icon exactly 16x16, gray-scaled, nothing but gray and white (the gray color being hex value 616161), to create a silhouette of my application icon.
Yet no matter what it just shows up as a white/gray square in the notifications. What am I doing wrong?
(My min api is 21, assuming it is relevant)

Follow this link
First let’s understand the Android documentation which is as follows
“Update or remove assets that involve color. The system ignores all
non-alpha channels in action icons and in the main notification icon.
You should assume that these icons will be alpha-only. The system
draws notification icons in white and action icons in dark gray.”
Now this is easy to miss and I have seen many apps that are live in the app store with thousands of users who haven’t followed the mentioned guidelines.
So let me explain in detail how you can convert your notification icon to an Android friendly one with a few clicks.
In your favourite image editor open up your icon file. Convert all parts of the image that you don’t want to show to transparent pixels. All colors and non transparent pixels are displayed in white. Let us go through an example.
EDITED: Thanks #Andrey Patseiko for the tool

For notification you have to use different icons for different versions of android:
Notification notification = new Notification.Builder(context)
.setAutoCancel(true)
.setContentTitle("My notification")
.setContentText("Look, white in Lollipop, else color!")
.setSmallIcon(getNotificationIcon())
.build();
return notification;
Get notification icon on the basis of version
private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
return useWhiteIcon ? R.drawable.icon_silhouette : R.drawable.ic_launcher;
}

Along with new features and capabilities, Android 5.0 includes a variety of system changes and API behavior changes. See the notification behavior changes.
Notifications are drawn with dark text atop white (or very light)
backgrounds to match the new material design widgets. Make sure that
all your notifications look right with the new color scheme. If your
notifications look wrong, fix them:
Use setColor() to set an accent color in a circle behind your icon image.
Update or remove assets that involve color. The system ignores all non-alpha channels in action icons and in the main notification icon.
You should assume that these icons will be alpha-only. The system
draws notification icons in white and action icons in dark gray.
So, basically you have to use silhouette icons as notification icon for API Level 21+

Related

Xamarin iOS change the default icon color to white in Light Mode

How do I display the dark mode icon while in Light mode on an iOS device? I have been searching this issue for months now and every post seems to come to dead end or the solutions just don't work. Using Xamarin 17.3 & VS 2022 and and developing an app for both Android & iOS. We have the Shell's background color (<Setter Property="Shell.BackgroundColor" Value="141B4D") which is a dark blue. The default, black icons (battery, time & etc.) don't show well with this background (its a company color and can't change it.) Android seems to handle this on its own and I didn't have to make any changes & the light icons show on the dark background in both Light & Dark modes. But on iOS in light mode the black icons display but cannot be seen. In dark mode the light icons show just fine.
Awhile back I tried a suggestion to to tell it, in the shared app, to use the dark mode icons in light mode.
<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Dark=Black, Light=#141B4D}" />
<Setter Property="Shell.ForegroundColor" Value="{AppThemeBinding Dark=White, Light=White}" />
But this doesn't work. So I really need some help in solving this. And if this is not the proper way to handle this a good alternative is welcomed.
Thanks
Based on your code, seems that you just want the text or icon in statusbar to be white if i understand correctly. So a simple way to achieve is to add the following code in AppDelegate:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
...
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
return base.FinishedLaunching(app, options);
}
Also, you have to add one key in info.plist
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
Note: in Property List Editor, it will show View controller-based status bar appearance
Then in dark blue background, you can also see white icon. The following picture is in light mode.
Hope it works for you.

3D Touch shortcuts - Color Icon

I know how to develop 3D touch shortcuts with customized icon (grayscale) but my question is is there any possiblility to put colored image as a shortcut icon? I have tried a colored image with
UIApplicationShortcutIcon *logoIcon = [UIApplicationShortcutIcon iconWithTemplateImageName:#"field_valid"]
...but it won't appear. With a grayscale icon, it is working fine.
Sure you can but only with contact images.
See UIApplicationShortcutIcon:
init(contact: CNContact)
Creates a Home screen quick action icon
from the picture for a contact if available, or else creates a
monogram from the contact name.
Source: https://developer.apple.com/documentation/uikit/uiapplicationshortcuticon
According to iOS Human Interface Guidelines, this is not permitted.
From the Home Screen Actions section:
Don't use an emoji in place of an icon. Emojis don't align properly with right-aligned text. Also, emojis are full color, whereas quick action icons are monochromatic.

iOS - Is it possible to change statusBarStyle to a custom colour?

I'm a beginner with iOS app development and want to customize the Status Bar colour. I have set my scene to a dark background and I want to battery and time in the Status Bar to match the colour.
At the moment I have added
var navigationBarAppearace = UINavigationBar.appearance()
UIApplication.shared.statusBarStyle = .lightContent
in AppDelegate.swift
Is there a way to add a custom hex colour for the text, not background?
I'm afraid there isn't without accessing private API's, which will get your app declined from apple review.
It's best to just find a way to make your app design work with the given, white or black status bar style.
The one thing you could do is create your own status bar that imitated the UIStatusBar, with your own labels and icons, but that would be a reasonable amount of hassle.

Foursquare API place icon background color

I have been using Foursuare API to list nearby places in my IOS app.Following is the url to get the icon image:
https://ss1.4sqi.net/img/categories_v2/food/default_64.png
Response is white icon with white background color. So its not seen in my App. Please suggest me a way to get the icon with different colors.
If you insert bg into the URL, you can get a version of the icon with a background color: https://ss1.4sqi.net/img/categories_v2/food/default_bg_64.png
See our full category documentation for more info!

Notification Center - Can you replace the bullet icon?

I'm trying to replace the blue bullet icon in the notification center for my app.
I thought that alertLaunchImage would allow me to do this. I have tried doing something like
not.alertLaunchImage = #"customBullet";
but it keeps the default blue bullet. Is the bullet customizable at all?
Update
In the screenshot below, i'm trying to customize the blue bullet on the left. I know already how to customize the main image (in this case the gmail icon)
Nope. It just means "new message" and it's managed by the system, not the apps.

Resources