Android Firebase多推送通知不工作

Android Firebase多推送通知不工作,android,firebase,Android,Firebase,如果我使用firebase向我的应用程序发送3推送数据通知,则我首先单击的那一推送数据通知只会打开,所有数据都会显示,而其余2推送数据则不会打开我的应用程序。下面是我给的接收数据信息的代码,请看一下 private void sendNotification(String message, Bitmap image, String objIdOS, String objIdVenInv, String typeVenInv, String cls, String checkTest, Stri

如果我使用firebase向我的应用程序发送3推送数据通知,则我首先单击的那一推送数据通知只会打开,所有数据都会显示,而其余2推送数据则不会打开我的应用程序。下面是我给的接收数据信息的代码,请看一下

 private void sendNotification(String message, Bitmap image, String objIdOS, String objIdVenInv, String typeVenInv, String cls, String checkTest, String colName, String title, String position) {
    Intent intent = new Intent(this, UserLogin.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("objIdOS",objIdOS);
    intent.putExtra("objIdVenInv",objIdVenInv);
    intent.putExtra("typeVenInv",typeVenInv);
    intent.putExtra("cls",cls);
    intent.putExtra("checkTest",checkTest);
    intent.putExtra("colName",colName);
    intent.putExtra("pos",position);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setContentTitle(title)
            .setContentText(message)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
            .setAutoCancel(true)
            .setSound( Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.clean))
            .setOnlyAlertOnce(true)
            .setPriority(Notification.PRIORITY_MAX)
            .setContentIntent(pendingIntent)
            .setColor(Color.parseColor("#1ABC9C"))
            .setSmallIcon(R.drawable.small_icon);
    if (image!=null){
        notificationBuilder.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(image).setSummaryText(message));  /*Notification with Image*/
    }

    /*if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        notificationBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.splash_icon3));
    } else {
        notificationBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.splash_icon3));
    }*/

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

    notificationManager.notify(notificationId, notificationBuilder.build());
}
加上这个

    (int)SystemClock.currentThreadTimeMillis()

    PendingIntent.getActivity(this, (int)SystemClock.currentThreadTimeMillis() /* Request code */, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);


notificationManager.notify((int)SystemClock.currentThreadTimeMillis(), notificationBuilder.build());
换这些 从


它将生成随机请求代码,以便在点击时可以打开多个通知。

请解释我做错了什么,以及这将如何帮助您?是的,由于相同的通知挂起意图id,您的数据被覆盖。因此,您需要为每个要显示的通知创建一个新id。不,我每次都从ARC更改通知id。通知在那里,但当我在打开第一个通知后打开它时,它什么都没有。您必须更改挂起的通知id。已解决此问题
  PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

  PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,PendingIntent.FLAG_ONE_SHOT);
int requestCode = new Random().nextInt();
PendingIntent contentIntent = PendingIntent.getActivity(this, requestCode, 
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);