Sending push notifications. Come as expected. Below is an example sent 3 notifications. When you click ON ANY notification for the first time, ViPe Activation opens with the data of the FIRST PUSH notification. Although different data must be transmitted. It can be seen from the screenshot that the id is different. When you click on the rest, nothing happens. What could be the reason?

public class MyFirebaseMessagingService extends FirebaseMessagingService { private static final String TAG = "MyFirebaseMsgService"; @Override public void onMessageReceived(RemoteMessage remoteMessage) { if (remoteMessage.getData().size() > 0) { Log.d(TAG, "Message data: " + remoteMessage.getData()); } Map<String, String> data = remoteMessage.getData(); String idz = data.get("idz"); String idp = data.get("idp"); String statusnotif = data.get("statusnotif"); int notifz = Integer.parseInt(data.get("idz")); String pbody = remoteMessage.getNotification().getBody(); String ptitle = remoteMessage.getNotification().getTitle(); if (remoteMessage.getNotification() != null) { sendNotification(pbody,ptitle ,idz,idp,notifz); } } 

.

 private void sendNotification(String body, String title,String idz,String idp,int notifz) { Intent intent = new Intent(this,ViPe.class ); intent.putExtra("idp", idp); intent.putExtra("idz", idz); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0/*Request code*/, intent, PendingIntent.FLAG_ONE_SHOT); //Set sound of notification Uri notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notifiBuilder = new NotificationCompat.Builder(this, "z"+idz) .setSmallIcon(R.mipmap.ic_launcher) .setColor(Color.GRAY) .setContentTitle(title+' '+idz+' '+idp) .setContentText(body) .setTicker(title) .setLights(Color.GREEN, 500, 1000) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setAutoCancel(true) .setSound(notificationSound) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(notifz, notifiBuilder.build()); } 

enter image description here

  • Do you use the PendingIntent.FLAG_ONE_SHOT flag for any particular purpose and hope for some special behavior that is different from what is stated in the documentation? - Yura Ivanov

0