Android通知图标问题
我有一个奇怪的问题。我有两种方式在我的Android应用程序中发送通知;一个来自Android服务,另一个通过FCM 情况如下:Android通知图标问题,android,push-notification,firebase-cloud-messaging,Android,Push Notification,Firebase Cloud Messaging,我有一个奇怪的问题。我有两种方式在我的Android应用程序中发送通知;一个来自Android服务,另一个通过FCM 情况如下: 无论应用程序是否正在运行,Android服务发送的通知图标都会正确显示 当应用程序运行时,如果我通过FCM发送通知,通知图标仍然正确显示 但是,如果应用程序没有运行,并且我通过FCM发送通知,则会显示一个白色方块,而不是通知图标 FCMService中的我的代码: Uri defaultSoundUri= RingtoneManager.getDefaultUri(R
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());
这是github fcm页面中详述的FMC错误
您的问题很可能是
通知消息
和数据消息
之间的差异
请阅读:
当您希望FCM处理显示文件时,请使用通知消息
代表您的客户端应用程序发出通知。使用数据消息时
要处理客户端应用程序上的消息
当前FCM Web控制台仅发送通知消息
因此,通过Web控制台(或通过带有通知的API
有效负载)发送的所有消息都将以这种方式:
onMessageReceived()
onMessageReceived()
始终被调用:然后,您需要使用
仅数据(无通知)消息无法找到该消息是否已修复。你对@seyfx有什么线索吗?你能解释一下“有两种方式发送通知”是什么意思吗?