• <bdo id='g4fd2'></bdo><ul id='g4fd2'></ul>

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

      <tfoot id='g4fd2'></tfoot>

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

      2. Firebase 两次发送推送通知

        时间:2023-07-30
        <legend id='9ItJX'><style id='9ItJX'><dir id='9ItJX'><q id='9ItJX'></q></dir></style></legend>
        <i id='9ItJX'><tr id='9ItJX'><dt id='9ItJX'><q id='9ItJX'><span id='9ItJX'><b id='9ItJX'><form id='9ItJX'><ins id='9ItJX'></ins><ul id='9ItJX'></ul><sub id='9ItJX'></sub></form><legend id='9ItJX'></legend><bdo id='9ItJX'><pre id='9ItJX'><center id='9ItJX'></center></pre></bdo></b><th id='9ItJX'></th></span></q></dt></tr></i><div id='9ItJX'><tfoot id='9ItJX'></tfoot><dl id='9ItJX'><fieldset id='9ItJX'></fieldset></dl></div>
          <tbody id='9ItJX'></tbody>
          <tfoot id='9ItJX'></tfoot>

            <small id='9ItJX'></small><noframes id='9ItJX'>

              • <bdo id='9ItJX'></bdo><ul id='9ItJX'></ul>

                • 本文介绍了Firebase 两次发送推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我编写了一个非常简单的 android 应用程序来测试 firebase 推送通知,我收到了两次通知.

                  I wrote a very simple android app to test firebase push notification and I get one notification twice.

                  这是清单服务:

                  <service
                          android:name="com.google.firebase.messaging.FirebaseMessagingService">
                          <intent-filter>
                              <action android:name="com.google.firebase.MESSAGING_EVENT"/>
                          </intent-filter>
                      </service>
                      <service
                          android:name="com.google.firebase.iid.FirebaseInstanceIdService">
                          <intent-filter>
                              <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
                          </intent-filter>
                      </service>
                  

                  这是应用程序 gradle:

                  this is the app gradle:

                      compile 'com.google.android.gms:play-services:9.0.0'
                      compile 'com.google.firebase:firebase-core:9.0.0'
                      compile 'com.google.firebase:firebase-messaging:9.0.0'
                  }
                  apply plugin: 'com.google.gms.google-services'
                  

                  这是项目级别的gradle:

                  and here is the project level gradle:

                  classpath 'com.google.gms:google-services:3.0.0'
                  

                  推荐答案

                  看起来你正在使用 com.google.android.gms:play-services:9.0.0(其中包括 play-services-gcm) 和 com.google.firebase:firebase-messaging:9.0.0

                  It looks like you are using com.google.android.gms:play-services:9.0.0 (which includes play-services-gcm) and com.google.firebase:firebase-messaging:9.0.0

                  来自 firebase-massaging 的 FCM 会自动注册一个实例 ID 令牌(设备 ID),因此如果您有在应用中注册令牌的逻辑,则您可能会注册两次.这可能会导致您收到多个通知.更一般地说,尽管出于这个原因,您不应该在同一个应用程序中使用 FCM 和 GCM.因此,如果您要使用 FCM,您应该从您的应用中移除 GCM.

                  FCM from firebase-massaging automatically registers an Instance ID token (device ID) so if you have logic that registers for a token in your app it is likely that you are registering twice. This could account for you receiving multiple notifications. More generally though you should not use FCM and GCM in the same app for exactly this reason. So if you are going to use FCM you should remove GCM from your app.

                  此外,使用 play-services 包括所有 play-services-x API,例如 play-services-gcm 和 play-services-drive 等.所以请始终使用拆分库,例如 play-services-x 而不仅仅是 play-services.

                  Also, using play-services includes all the play-services-x APIs like play-services-gcm and play-services-drive etc. So always use the split libraries like play-services-x instead of just play-services.

                  这篇关于Firebase 两次发送推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为每个用户创建 Firebase 主题 下一篇:Firebase 消息传递 - 当应用程序在后台时创建平视显示

                  相关文章

                  • <bdo id='teYQq'></bdo><ul id='teYQq'></ul>

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

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