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.
Related
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 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)
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.
I'm using ionic to build an android app. I'm using
$cordovaLocalNotification for local notifications. The notification works but it shows a default bell icon. How can I customize the notification icon?
$scope.scheduleSingleNotification = function () {
$cordovaLocalNotification.schedule({
id: 1,
title: 'GRM APP Builder',
text: 'Quer café?!?',
badge: 1,
icon: 'res://coffee.png',
data: {
customProperty: 'custom value 1'
}
}).then(function (result) {
console.log('Notification 1 triggered');
});
};
After spend hours with this question, I saw that one comment above it's really right.
If you want to change icon, you need to create a folder called "drawable" in "[my ionic app folder]\platforms\android\res\drawable".
But the trick is: after this you need to quit your livereload mode and execute again CLI command "ionic run android -l -c -s". It's necessary because you need to copy new assets to device.
I only tested with Android device, if you can test with iOS please send a review here.
According to this post on the forum, you can simply set the notification's icon and smallIcon properties. You have to put the files into /platforms/android/res/drawable/ folder. (also mind that the icon has to be started with 'res://somename')
Note: You shall replace ngCordova's notification handling functions, since they are faulty.
In the latest ionic-cli 3,
Copy your icon.png into the following folder.
platforms/android/res/drawable/icon.png
Note that this is in android only.
Once this is done( make sure that the image is a transparent icon),
next step is to initialize this icon in the notification.init function.
Now if we you are using push plugin
do the following;
const pushObj: PushObject = this.push.init({
android: {
senderID: "your_id",
icon: "icon",
forceShow: "true"
},
ios: {
alert: "true",
badge: "true",
sound: "true"
}
});
As you can see that the Only the name of the icon is added not the extenstion.
Once this is done, include a same key value pair in the server side code as well, which pushes the notification into your device.
All will be working well.