FCM Notification icon

I use FCM notificatoin. It works but when the notification comes I have no icon. I know that I can push 'icon' => 'someicon' to FCM service but what should I put into someicon? I my app I have platforms/android/res/mipmap-xhdpi/icon.png but I also have other folders with the same icon.

HI! Can you share your code for Push Notification with FCM worked?

I tried to find a solution but i canā€™t since 4 days . I found a lot of issuesā€¦

Thanks and Regards,

Did you register on Google FCM?

You need to download google-services.json and put it inside /platforms/android and where you have ā€œpackage_nameā€ you need to put you package name from config.xml (probably second line - )

This is app.js:
angular.module(ā€˜starterā€™, [ā€˜ionicā€™, ā€˜starter.controllersā€™, ā€˜starter.servicesā€™])
.run(function($ionicPlatform, $ionicPopup, $state) {

  $ionicPlatform.ready(function() {

      FCMPlugin.getToken(
        function(token){

          FCMPlugin.subscribeToTopic('sometopic');

        },
        function(err){
          console.log('Notification errpr');
        }
      )

      FCMPlugin.onNotification(
        function(data){

          if (data.wasTapped) {
            // Notification was received on device tray and tapped by the user.
 			// Doesn't work for me 
          } else {
            //Notification was received in foreground. Maybe the user needs to be notified.
            alert("You have some notification:" + data.someValue);
          }
        },
        function(msg){
          console.log("Something");
        },
        function(err){
          console.log("Error");
        }
      );

    //}

  });
})
1 Like

You can generate icon here:
https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.space.trim=1&source.space.pad=0&name=ic_stat_example
After that put it in resources/android/ic_notifications directory
(i.e.: resources/android/ic_notifications/drawable-hdpi/my_icon.png)

In your FCM service set just:
ā€˜iconā€™ => 'my_iconā€™
without extension.

1 Like

I generated standard app icion and I have icon in /resources/android/icon/drawable-hdpi-icon.png. Should it be always on ic_notifications folder? Now I just have icon' => 'my_icon but does not work on my phone. On others phones it works - older and newer Android, I have 5.1.1 version.

Hi @hbmedia,

My push notifications works as expected but I have no icon.

Did you get it to work properly?

Does ionic-cli have one way of doing it? (ionic resources)

Thanks!