I am sending a Firebase Cloud Messaging notification to my Android app, but the icon on the notification is not showing correctly. its on nexus I'm having the trouble (KitKat).
and im using the following sdk:
minSdkVersion 19
targetSdkVersion 24
The image (.png) is a logo I am pulling from the drawable folder and it looks like this:
But now when I use it in my notification it looks like this:
Keep in mind I am sending the notification using an API call like this:
https://fcm.googleapis.com/fcm/send
and the post body looks like this:
{ "notification": {
"title": "Your Title",
"text": "Your Text",
"click_action": "OPEN_ACTIVITY_1"
},
"data": {
"keyname": "some data item name "
},
"to":"eZm-5IM8dkE:APA91bFkC9kZSgZblDr_4JBB-MNOCkITsRGSECykFzXQE70zzM8rShP66pPYIX4iBio3V9sN1Go1q4o6dGhybm6SPRio3asC-6NIltzQfc0ZlmWrexxxxxxxxxxxxxxxiHygCx2y"
}
I noticed I am not setting the icon anywhere, but I don't think that's the issue. Notice how its a parallelogram in both images, so I think its just processing it differently. What am I doing wrong?
also note in the Android Manifest, I have set the following:
<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/mylogo" />
FCM is showing your icon correctly but Android (not FCM) is changing the icon color to white.
This is the standard behavior of Android and is documented here:
https://developer.android.com/about/versions/android-5.0-changes.html#BehaviorNotifications
(see the last paragraph under Notifications > Material design style)
Related
I'm using one signal within my flutter app and everything is fine except the notifications have no icon ( comes with a default bill icon ).
I have read the documentation for one signal and generated an AssetsImage by Android Studio in PROJECT/android/res/ with name ic_stat_onesignal_default
Then I built the app using the command flutter run --release on a real device and still, the notification comes with default bill icon instead of my app icon!!
Is there some code required in the AndroidManifest.xml file too?
use these tool and upload image that is trnasperts
http://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=image&source.space.trim=1&source.space.pad=0&name=ic_stat_onesignal_default
for onesignal the folders names is drawable-xxxx
so you just download from the tool and extract inside the android\app\src\main\res
Note :-
Starting with Android 5, the OS forces Small Notification Icons to be all white when your app targets Android API 21+. If you don't make a correct icon, it will most likely be displayed as a bell or solid white icon in the status bar.
just do some simple things and it changes your default notification icon. I also face this problem in 2021 but I resolve it
in AndroidManifest.xml
<meta-data
android:name="com.onesignal.messaging.default_notification_icon"
android:resource="#mipmap/ic_stat_onesignal_default" />
in build.gradle
buildTypes {
debug {
defaultConfig {
manifestPlaceholders = [onesignal_app_id : "your onesignal app id put here",
onesignal_google_project_number: "your project number put here"]
}
}
}
put your pic in app/main/res/drawable and also in all mipmap with the name "ic_stat_onesignal_default" ..please must use this name otherwise it's not working ..
I've been trying to change the notification icon of the Firebase Cloud notifications in Unity.
I tried copying the icon folder structure from the sample at https://github.com/firebase/quickstart-android/tree/master/messaging/app/src/main to Assets/Plugins/Android/Res so I can test with icons that are known to work, and modifying my Manifest with the
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="#drawable/ic_stat_ic_notification"/> tag.
However it still keeps using the app icon, also when using the default_notification_color tag used in the sample the notifications don't change.
Solved by removing the meta-data from the manifest, so only having the icon in the res folder in the app.
Then referencing the icon via the notification JSON:
{
"to": "<Key>",
"collapse_key": "type_a",
"notification": {
"body": "Body of Your Notification",
"title": "Title of Your Notification",
"icon": "notification_icon_name",
"color": "#0000C0"
}
}
This properly showed the icon and changed the color when the status bar was opened.
I want my FCM notifications to include a custom image and a vibration pattern.
The AndroidNotification class that Firebase provides as an example has both of these variables, but I haven't seen any way to get it working.
I've tried adding both of these variables to my notification message through a c# class AndroidNotification which gets serialized to json.
This is the documentation that makes me think it should be possible
https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages
I have watched multiple online videos and went through multiple forms, but have still been unable to set a custom vibration pattern or display image along with my app icon.
Lots of places suggest that I use a data only message so I can handle displaying the notification myself, but if that is the only way to do it way does the AndroidNotification documentation(linked above) show fields for both vibrate_timings and image?
Note :
I've been testing on Android Versions 4, 5, and 8. On 8 I set up a notification channel and everything works fine with that including the vibrations, but still no image.
The image is included locally in the my apk at the same path as my custom icon.
Also my apk is built with unity but I don't think that should effect things.
Here is the json payload I'm sending, I get my custom sound, custom icon, custom color etc just fine, it's only the image and vibrate_timings that don't seem to be working.
{
"validate_only":false,
"message":{
"data":null,
"android":{
"collapse_key":"new_messages",
"priority":1,
"restricted_package_name":"",
"data":{
},
"notification":{
"title":"A spoon is ready!",
"body":"Grab it before someone else!",
"icon":"spoonsbuzz",
"channel_id":"cow",
"color":"#0000FF",
"sound":"cow.wav",
"vibrate_timings":[
"0.0s",
"0.2s",
"0.1s",
"0.2s",
"0.1s",
"1.5s"
],
"visibility":2,
"tag":"new_messages",
"click_action":"",
"body_loc_key":"",
"body_loc_args":[
],
"title_loc_key":"",
"title_loc_args":[
],
"image":"spoonsbuzzimage",
"notification_priority":4
}
},
"apns":null,
"token":"Bot"
}
}
I expected my devices to get a notification with the image I added to the payload as well as vibrate in the pattern I set using vibrate_timings. The notification does come in just fine and everything else works but neither the image or the custom vibrations are included.
It's been a long time, but if someone has this problem they should add the default_vibrate_timings field, like this:
{...
default_vibrate_timings: false,
vibrate_timings: [
"0.0s",
"0.2s",
"0.1s",
"o.2s"
],
...}
For reference: Documenation Link
I'm trying to change de blank square in ionic push notification. When I send the request changing the icon, it doesn't works.
...
"notification": {
"title": "title",
"message": "message",
"android": {
"icon": "icon"
}
}
...
But, when I send the request with the SAME file 'icon' but to change de image it works
...
"notification": {
"title": "title",
"message": "message",
"android": {
"image": "icon"
}
}
...
Anyone already faced that problem?
I'm using phonegap-plugin-push and I've already seen the documentation, but without success.
Thanks in advance!
I didn't know where the plugin was searching for the icon file to insert in the push notification icon, so I've tried to search more in it documentation.
Searching in phonegap-plugin-push documentation, I've found a section that explains how phonegap-build works and this section has a topic adding-resources, which is a beta feature to add resource files automatically in Android platform, but this doesn't work (at least not for me).
So I've tried to create the folder with the icon file manually (the same folder which is discribed in documentation) in the Android drawable folder and it works!!
PLUS: I've tested in Android 6.* and it just recognize solid, black and white and .png push notification icon file.
I hope this question can helps you!!
in ionic push notifications, we can add "icon":"xxxxx" in "android" array to change a new (small) icon path ,
var push = new Ionic.Push({
"debug": true,
"pluginConfig": {
"android": {
"iconColor": "#343434",
"icon": "abc"
}
}
});
where the abc.png is from platform/android/res/drawable folder.
but is there any methods to change the push's large icon? Since, the iconColor is valid but I test lots of times , I cant change the color background to a large image.
anyone can help me.. Thanks!!
You can add an image property to the android object which is a string describing either a reference to an image in the drawables folder, an asset URI, or a remote URL. Although Ionic Push doesn't list itself as supporting this property, actual testing verifies it.
More information: https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#images
Currently there is no support for the large icon through the FCM notification message payload.
See https://github.com/firebase/quickstart-android/issues/84 . The problem is known but the issue is closed.