I have a strange problem. I have two ways to send notifications in an Android app; one from the Android service and the other through FCM.
The scripts are as follows:
- Regardless of whether the application is running or not, the notification icon sent from the Android service is displayed correctly.
- When the application is running, the notification icon still displays correctly if I send a notification through FCM.
- But if the application is not running, and I send a notification through FCM, a white square is displayed instead of the notification icon.
My code in FCMService:
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("Android App") .setContentText(messageBody) .setAutoCancel(true) .setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build());
seyfx source share