[英]app crashes (only on Marshmallow(6.0.1)) when i send firebase push notification while app is on foreground but works fine when in background
Here is the code for the Firebase Messaging service: 这是Firebase Messaging服务的代码:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
To show notification in foreground: 要在前台显示通知:
private void showNotification(String title, String body) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String NOTIFICATION_CHANNEL_ID = "com.shijan.qrscannerict.test";
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID);
notificationBuilder.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ict_logo)
.setContentTitle(title)
.setContentText(body)
.setContentInfo("Info");
notificationManager.notify(new Random().nextInt(), notificationBuilder.build());
}
The issue is fixed. 该问题已解决。 The problem was that the app(Marshmallow) was not being able to extract the notification icon that I set.
问题是该应用程序(棉花糖)无法提取我设置的通知图标。 The app worked when I created a new image asset for the notification icon in the res directory.
当我在res目录中为通知图标创建新的图像资产时,该应用程序正常运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.