<bdo id='u6KHl'></bdo><ul id='u6KHl'></ul>
  1. <i id='u6KHl'><tr id='u6KHl'><dt id='u6KHl'><q id='u6KHl'><span id='u6KHl'><b id='u6KHl'><form id='u6KHl'><ins id='u6KHl'></ins><ul id='u6KHl'></ul><sub id='u6KHl'></sub></form><legend id='u6KHl'></legend><bdo id='u6KHl'><pre id='u6KHl'><center id='u6KHl'></center></pre></bdo></b><th id='u6KHl'></th></span></q></dt></tr></i><div id='u6KHl'><tfoot id='u6KHl'></tfoot><dl id='u6KHl'><fieldset id='u6KHl'></fieldset></dl></div>

  2. <tfoot id='u6KHl'></tfoot>
  3. <legend id='u6KHl'><style id='u6KHl'><dir id='u6KHl'><q id='u6KHl'></q></dir></style></legend>

    <small id='u6KHl'></small><noframes id='u6KHl'>

    1. 如何阻止新的推送通知被 Firebase 中的旧推送通知替换?

      How to stop new push notification being replaced by the old one in Firebase?(如何阻止新的推送通知被 Firebase 中的旧推送通知替换?)
      <legend id='LI7s9'><style id='LI7s9'><dir id='LI7s9'><q id='LI7s9'></q></dir></style></legend>

          <bdo id='LI7s9'></bdo><ul id='LI7s9'></ul>

          <tfoot id='LI7s9'></tfoot>
            <tbody id='LI7s9'></tbody>
            <i id='LI7s9'><tr id='LI7s9'><dt id='LI7s9'><q id='LI7s9'><span id='LI7s9'><b id='LI7s9'><form id='LI7s9'><ins id='LI7s9'></ins><ul id='LI7s9'></ul><sub id='LI7s9'></sub></form><legend id='LI7s9'></legend><bdo id='LI7s9'><pre id='LI7s9'><center id='LI7s9'></center></pre></bdo></b><th id='LI7s9'></th></span></q></dt></tr></i><div id='LI7s9'><tfoot id='LI7s9'></tfoot><dl id='LI7s9'><fieldset id='LI7s9'></fieldset></dl></div>

              • <small id='LI7s9'></small><noframes id='LI7s9'>

              • 本文介绍了如何阻止新的推送通知被 Firebase 中的旧推送通知替换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                当我触发推送通知时,旧的会被新的替换.但我希望它应该添加到那个旧通知中.

                When I trigger a push notification then the old one is replaced by new one. But I want it should add to that old notification.

                我的 MyFirebaseMessaging 类是:

                My MyFirebaseMessaging class is:

                public class MyFirebaseMessaging  extends FirebaseMessagingService {
                    String title="";
                    String message,type,click_action;
                    int no_of_messages;
                
                    @Override
                    public void onMessageReceived(RemoteMessage remoteMessage) {
                        super.onMessageReceived(remoteMessage);
                
                        if(remoteMessage.getData().size()>0) {
                            message = remoteMessage.getData().get("body");
                            title = remoteMessage.getData().get("title");
                            click_action = remoteMessage.getData().get("click_action");
                            no_of_messages++;
                            ShowNotification(message);
                        }
                        else
                            Log.i("remoteMessage",message);
                    }
                
                    private void ShowNotification(String message) {
                        Intent intent = new Intent(click_action);
                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        intent.putExtra("loading_flag","load");
                        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
                        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                        String NOTIFICATION_CHANNEL_ID = "my_channel_id_01";
                        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                            @SuppressLint("WrongConstant")
                            NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "My Notifications", NotificationManager.IMPORTANCE_MAX);
                
                            // Configure the notification channel.
                            notificationChannel.setDescription("Channel description");
                            notificationChannel.enableLights(true);
                            notificationChannel.setLightColor(Color.RED);
                            notificationChannel.setVibrationPattern(new long[]{0, 1000, 500, 1000});
                            notificationChannel.enableVibration(true);
                            notificationManager.createNotificationChannel(notificationChannel);
                        }
                
                        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this,NOTIFICATION_CHANNEL_ID);
                        // if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        //   notificationBuilder.setSmallIcon(R.drawable.vadodaramunicipalcorporation);
                        //  notificationBuilder.setColor(getResources().getColor(R.color.backgroundColor));
                        //  } else {
                        //     setSmallIcon(R.drawable.vadodaramunicipalcorporation)
                        //  }
                        notificationBuilder.setSmallIcon(R.mipmap.vadodaramunicipalcorporation)
                            .setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.mipmap.vadodaramunicipalcorporation))
                            .setContentTitle("You have new "+ title)
                            .setDefaults(Notification.DEFAULT_ALL)
                            .setWhen(System.currentTimeMillis())
                            .setTicker("Hearty365")
                            .setContentInfo("Info")
                            .setContentText(message+" new Alerts")
                            .setNumber(no_of_messages)
                            .setAutoCancel(true)
                            .setSound(defaultSoundUri)
                            .setStyle(new NotificationCompat.BigTextStyle())
                            .setContentIntent(pendingIntent)
                            .setPriority(Notification.PRIORITY_MAX);
                        notificationManager.notify(0, notificationBuilder.build());
                    }
                }
                
                
                {
                    "to":"token-key",
                    "data" : {
                         "body" : "4",
                          "title" : "Alert",
                          "click_action" : "Activity.DATA_CLICK"
                    }
                }
                

                推荐答案

                在我的应用程序中,新的推送通知被替换为 firebase 推送通知中的旧推送通知,我将如何停止此操作

                new push notification is replaced the old one in firebase push notification in my application,How i will stop this

                你需要在notificationManager.notify()

                You need to pas different notificationID in notificationManager.notify()

                示例代码

                Date myDate = new Date();
                int myNotificationId = Integer.parseInt(new SimpleDateFormat("ddhhmmss",  Locale.US).format(myDate));
                notificationManager.notify(myNotificationId,notificationBuilder.build());
                

                这篇关于如何阻止新的推送通知被 Firebase 中的旧推送通知替换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
                cocos2d-android: how to display score(cocos2d-android:如何显示分数)
                Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
                SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
                Android file copy(安卓文件拷贝)
                Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)
                <i id='XYLlM'><tr id='XYLlM'><dt id='XYLlM'><q id='XYLlM'><span id='XYLlM'><b id='XYLlM'><form id='XYLlM'><ins id='XYLlM'></ins><ul id='XYLlM'></ul><sub id='XYLlM'></sub></form><legend id='XYLlM'></legend><bdo id='XYLlM'><pre id='XYLlM'><center id='XYLlM'></center></pre></bdo></b><th id='XYLlM'></th></span></q></dt></tr></i><div id='XYLlM'><tfoot id='XYLlM'></tfoot><dl id='XYLlM'><fieldset id='XYLlM'></fieldset></dl></div>
                  <tbody id='XYLlM'></tbody>
                • <bdo id='XYLlM'></bdo><ul id='XYLlM'></ul>

                  1. <tfoot id='XYLlM'></tfoot>

                    <small id='XYLlM'></small><noframes id='XYLlM'>

                        <legend id='XYLlM'><style id='XYLlM'><dir id='XYLlM'><q id='XYLlM'></q></dir></style></legend>