NotificationCompat.BigPictureStyle 显示问题
NotificationCompat.BigPictureStyle display issue
我面临的问题对我来说很奇怪,搜索 google 进行修复,但没有得到任何相关的解决方案。
问题 --
我正在使用云消息传递从 Firebase 面板发送推送通知。当应用程序打开时,我可以查看带有小徽标、标题、内容文本和大图像的通知。
但是当应用程序关闭时,收到的通知只显示小徽标、标题和内容文本。大图不显示。
可能是什么问题?
我正在发送我正在使用的代码片段 --
NotificationCompat.BigPictureStyle bpStyle = new NotificationCompat.BigPictureStyle();
bpStyle.bigPicture(BitmapFactory.decodeResource(getResources(), R.drawable.vm_notification_banner)).build();
mBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID);
mBuilder.setContentTitle(title)
.setContentText(msg)
.setSmallIcon(R.drawable.vswhitenoti)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.vswhitenoti))
.setOnlyAlertOnce(true)
.setContentIntent(pendingIntent)
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(NotificationManager.IMPORTANCE_MAX)
.setStyle(bpStyle);
mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build());
您在 docs 中遗漏了一个小细节。
App state Notification Data Both
Foreground onMessageReceived onMessageReceived onMessageReceived
Background System tray onMessageReceived Notification: system tray
您的消息在后台而不是 onMessageReceived 发送到系统托盘,这就是您看不到 BigImageStyle 的原因。
如果你想要每次都简洁直接的控制,使用数据通知。
我面临的问题对我来说很奇怪,搜索 google 进行修复,但没有得到任何相关的解决方案。
问题 -- 我正在使用云消息传递从 Firebase 面板发送推送通知。当应用程序打开时,我可以查看带有小徽标、标题、内容文本和大图像的通知。
但是当应用程序关闭时,收到的通知只显示小徽标、标题和内容文本。大图不显示。
可能是什么问题?
我正在发送我正在使用的代码片段 --
NotificationCompat.BigPictureStyle bpStyle = new NotificationCompat.BigPictureStyle();
bpStyle.bigPicture(BitmapFactory.decodeResource(getResources(), R.drawable.vm_notification_banner)).build();
mBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID);
mBuilder.setContentTitle(title)
.setContentText(msg)
.setSmallIcon(R.drawable.vswhitenoti)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.vswhitenoti))
.setOnlyAlertOnce(true)
.setContentIntent(pendingIntent)
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(NotificationManager.IMPORTANCE_MAX)
.setStyle(bpStyle);
mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build());
您在 docs 中遗漏了一个小细节。
App state Notification Data Both
Foreground onMessageReceived onMessageReceived onMessageReceived
Background System tray onMessageReceived Notification: system tray
您的消息在后台而不是 onMessageReceived 发送到系统托盘,这就是您看不到 BigImageStyle 的原因。
如果你想要每次都简洁直接的控制,使用数据通知。