2017-10-11 24 views
1

firebaseを使用してアプリケーションに3プッシュデータ通知を送信すると、最初にクリックしたものが開き、すべてのデータが表示されます。以下は、データメッセージを受け取るための私の与えられたコードです。見てください。Firebase複数プッシュ通知が機能しない

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()); 
} 

答えて

0

はuは私が間違っているのかを説明してくださいすることができ、この

(int)SystemClock.currentThreadTimeMillis() 

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


notificationManager.notify((int)SystemClock.currentThreadTimeMillis(), notificationBuilder.build()); 
+0

を追加し、これは役立ちますか? –

+0

はい、保留中の同じインテントIDのため、データが上書きされます。 これで、表示する通知ごとに新しいIDを作成できます。 –

+0

いいえ私は毎回ARCから通知IDを変更しています。通知はありますが、最初の通知を開いた後に開いたときには何もしません。 –

関連する問題