I have an app which receives the push notifications and display them even if screen is locked.
Icon shown in notification bar is not correct. My project is developed in flutter and app icon is working fine. Where exactly I need to keep the icon file to show correct icon on notification panel. Please refer image below.
Have you tried adding below code in your AndroidManifest.xml,
<!-- Set custom default icon. This is used when no icon is set for incoming notification messages.
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/ic_stat_ic_notification" />
For more read this
I did the following and it worked for me:
Create a transparent and white notification icon (you can use the following tool: AndroidAssetStudio )
Download the zip folder, unzip and you'll see it contains a res folder with different drawable folders. Copy and paste the contents of the res folder in "android\app\src\main\res" path
Then open the AndroidManifest.xml file and add the following lines to it:
ic_stat_calendar_today is the name of my notification icon. And each of the drawable folders that have been pasted contain a different size of icon with the same name.
If you want to change the color of the icon then check the above image. Add the metadata tag after the notification icon tag
Go to "android\app\src\main\res\values" and add a colors.xml file
<color name="colorAccent">#00FF00</color>
I have shared this answer in the following Github chain as well- Solution.
Related
I want to set a custom notification icon to appear in my notifications panel for my flutter app when i use fcm(firebase cloud messaging) but there is only a grey circle that appears and no icon .
After Searching for a long time i finally found the answer and here it is:
Create a custom notification icon using this tool.
Paste the generated list of icons in android/app/src/main/res.
Go to your manifest android/app/src/main/AndroidManifest.xml and add the following meta data in the application (not activity) tag:
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/ic_notification" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/colorPrimary" />
If you don't have a colors.xml in res/values, create one:
Done! It should work, let me know if it doesn't.
Discussion for the question is here.
I was wondering how one could use his own icons in a Flutter-Mapbox plugins' marker?
There's no default marker icon (no provided icon - no marker),
and there's not enough documentation on how to use a custom image.
adding a symbol (marker) is as follows:
mapController.addSymbol(
SymbolOptions(
geometry:LatLng(0.0, 0.0), // location is 0.0 on purpose for this example
iconImage: "pin"
)
);
whereas the IconImage, a String, is the field which should contain the data about the icon (obviously), but the given example repository doesn't clarify the needed parameters (url, path etc.).
Providing a path to the assets doesn't work (unlike other widgets). In the example, they provide the IconImage field the value airport-15, and when running the app, it actually works, but I can't seem to find the resources' location (it's not in #drawables or my assets folder, or any other place in the project)
You have to create a custom style on using MapBox Studio.
Create a new dataset if not already exist
Create tileset
Create new style & select customize basic template
Create new layer, give it a name for example my_sym and add newly created datasource
Then click on type & change it to symbol
Now click on my_sym two times. (first one will close the option menu & second one will open a new menu with symbol properties
Click on icon tab & select new icon. You can also upload your own svg icon.
Click on publish
Click on share it will show you the urls.
Copy the type of url & set styleString property.
For more info follow steps here
https://docs.mapbox.com/help/tutorials/add-points-pt-1/
API reference:
https://docs.mapbox.com/mapbox-gl-js/api/
As of release 0.0.5 it will be possible to load custom icon images for your markers. The idea is to add the icon image to your assets folder (for example: assets/symbols/custom-icon.png). If you specify this image as an asset in your pubspec.yaml and set the iconImage in the SymbolOptions to this path it will be loaded automatically.
Regarding the airport-15, this is an icon provided by the Android implementation of the plugin. It is part of the Maki Icons used in Mapbox. Because these icons are part of the Android implementation you will not find as a Flutter asset or an Android resource of the example app.
I'm new in flutter so please don't kill me if my question is easy.
notification icon doesn't show like this
I put in this path
\android\app\src\main\res\drawable
here is my code for icon:
final settingsAndroid = AndroidInitializationSettings('app_icon');
final settingsIOS = IOSInitializationSettings(onDidReceiveLocalNotification: (id, title, body, payload) => onSelectNotification(payload));
final settingsIOSgeneral = IOSInitializationSettings(onDidReceiveLocalNotification: (id, title, body, payload) => onSelectNotificationgeneral(payload));
notifications.initialize(InitializationSettings(settingsAndroid, settingsIOS), onSelectNotification: onSelectNotification);
Can Any one help me please how can I preview my icon in notification ?
I did the following and it worked for me:
Create a transparent and white notification icon (you can use the following tool: AndroidAssetStudio )
Download the zip folder, unzip and you'll see it contains a res folder with different drawable folders. Copy and paste the contents of the res folder in "android\app\src\main\res" path
Then open the AndroidManifest.xml file and add the following lines to it:
ic_stat_calendar_today is the name of my notification icon. And each of the drawable folders that have been pasted contain a different size of icon with the same name.
If you want to change the color of the icon then check the above image. Add the metadata tag after the notification icon tag
Go to "android\app\src\main\res\values" and add a colors.xml file
<color name="colorAccent">#00FF00</color>
I have shared this answer in the following Github chain as well- Solution.
This could be because the icon image is not transparent -- Try the notification icon generated from this tool. Also check this question Android Push Notifications: Icon not displaying in notification, white square shown instead
generate a transparent icon and then set the color in AndroidNotificationDetails parameter
You must do three things;
1.follow #user2549980's answer and do samethins step by step but in colors.xml file, you must write encoding="utf-8" with uppercase format, like;
(your notification icon must be copied mipmap folders with same sizes, and you must add that icon name to your AndroidManifest.xml, and it must be transparent icon.)
2.Step; in your local notification init function,
_notificationPlugin=FlutterLocalNotificationsPlugin();
await _notificationPlugin.initialize(
const InitializationSettings(
android: AndroidInitializationSettings('#mipmap/notification_icon'),
iOS: IOSInitializationSettings()
),
onSelectNotification: (payload) async{
},
);
you must change this line #mipmap/icon_name with your icon name.
and I am writing this comment because, this step can be missed easily so, don't forget this step.
(1) You don't have to put them in drawable, you can put them in mipmap (android/src/main/res/mip-map-**dpi folders) if you want.
(2) If you need to test the result, hotreload won't take effect, you have to rebuild to test the result.
I have uploaded my project to github account successfully but i am
able to add a demo image or gif to it.
You just need to follow the suggestion at the bottom of your screenshot: Add a README
There you can embed images, both still or moving
Click Add a README on your screen, or manually submit a file called README.md in the page that you want an image to be on (You can have a different README.md file on every folder)
In that file add a link to an image using this tag:
![screen shot](http://i.imgur.com/example.png)
I have issues showing a localized app icon with retina display support.
How could this be done?
I tried to make Icon.png and Icon#2x.png localized, then I tried to make the proj-Info.plist localized and try to link to different Images.
But only the Icon of the project language are being shown...
You need to create one infoplist.strings file for each of the language. For that, create language.lproj folders manually and put Infoplist.string file in each of the folder.
Inside the file enter the following: CFBundleIconFile="Icon_en.png" or CFBundleIconFile = "Icon_pt.png".