GCM push notification icon

GCM's official documentation here mentions how to put an icon for a push notification in this example

{
    "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "notification" : {
      "body" : "great match!",
      "title" : "Portugal vs. Denmark",
      "icon" : "myicon"
    }
  }

My question is: "myicon" is the name of the icon, where does it exist? For example: in my project in android studio in "myicon.png"? or where is it? Please someone explain and in advance in advance

+4
source share
1 answer

Use the icon of your application from drawable, for example .setSmallIcon(R.drawable.appicon), where appicon is a .pngfile from your folderdrawable

Or use this code:

  NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
         .setSmallIcon(R.drawable.icond)
         .setContentTitle("Start Launcher")
         .setContentText(message)
         .setAutoCancel(true)
         .setOngoing(true)
         .setWhen(System.currentTimeMillis())
         .setContentIntent(pendingIntent);

   NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);

   notificationManager.notify(ID_NOTIFICATION , notificationBuilder.build());
0
source

Source: https://habr.com/ru/post/1653267/


All Articles