Lots of people have been asking about this issue but all the solutions now seem to be outdated. I tried all the solutions but it's still not working for me using Phongap Build CLI9.0.0, Firebase Cloud for push notifications and phonegap-plugin-push 2.1.3.
I can add icons to my app with no problem. The correct logo is shown as expected when installing and loading the app up. However when I receive a push notification the icon in the tray area is just a white/grey square.
So far here's what I've tried:
My icon is a white circle with a transparent background. It is called notification_icon.png. I have made 6 different sized versions to meet the ldpi, hdpi etc requirements. I have added the icon name to the push notification init like so...
var push = PushNotification.init({
android: {
senderID: senderId,
iconColor: "#e73439",
alert: true,
badge: true,
icon: 'notification_icon',
sound: true,
vibrate: true,
},
ios: {
senderID: senderId,
iconColor: '#e73439',
alert: true,
badge: true,
icon: 'notification_icon',
sound: true,
vibration: true,
},
windows: {}
});
I have added all variants of the icon to my config.xml like so (the first 6 are my logo icons, not the notification icon)...
<platform name="android">
<icon density="ldpi" src="icons/android/icon36x36.png" />
<icon density="mdpi" src="icons/android/icon48x48.png" />
<icon density="hdpi" src="icons/android/icon72x72.png" />
<icon density="xhdpi" src="icons/android/icon96x96.png" />
<icon density="xxhdpi" src="icons/android/icon144x144.png" />
<icon density="xxxhdpi" src="icons/android/icon192x192.png" />
<icon src="icons/notification_icon96x96.png" target="res/drawable/notification_icon.png" />
<icon density="ldpi" src="icons/notification_icon36x36.png" target="res/drawable-ldpi/notification_icon.png" />
<icon density="mdpi" src="icons/notification_icon48x48.png" target="res/drawable-mdpi/notification_icon.png" />
<icon density="hdpi" src="icons/notification_icon72x72.png" target="res/drawable-hdpi/notification_icon.png" />
<icon density="xhdpi" src="icons/notification_icon96x96.png" target="res/drawable-xhdpi/notification_icon.png" />
<icon density="xxhdpi" src="icons/notification_icon144x144.png" target="res/drawable-xxhdpi/notification_icon.png" />
<icon density="xxxhdpi" src="icons/notification_icon192x192.png" target="res/drawable-xxxhdpi/notification_icon.png" />
</platform>
I even tried adding the icon to the FCM payload like so...
$notification = array
(
'body' => $message,
'title' => $titlenotification,
"icon" => 'notification_icon',
"content_available" => "1",
"image" => "push_notification" ,
"icon" => "push_notification" ,
"color" => "#e73439" ,
);
$data = array
(
"title" => $titlenotification,
"message" => $message,
"content_available" => "1",
);
$fields = array
(
'registration_ids' => $registrationtokens,
'notification' => $notification,
'data' => $data,
"priority" => "high",
"content_available" => true,
);
....etc
I am using Phponegap build to compile so I can't edit any other xml parts, just config.xml.
the only way I have had it work so far is if I removed my other logo icons and just use the notification icon - but then the notification icon is displayed as the main icon too.
I thought that perhaps just the smaller icons would be used as the notification icons so I tried using the notification icon for the ldpi, mdpi and hdpi and the main logo for the xhdpi, xxhdpi and xxxhdpi but no matter what I try the result is either the notification_icon works but it is also used as the logo when loading up the App, or the notification icon is ignored, the logo is used as the loading up icon and the white/grey square is used for the notification icon.
Can anyone help?