FCM Notification icon


#1

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.


#2

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,


#3

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");
        }
      );

    //}

  });
})

#4

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.


#5

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.


#6

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!