简体   繁体   中英

Firebase Cloud Messaging sends upstream message multiple times, although I send Acknowledge

I am developing an application that sends data through FCM to my server. According to the Firebase Docs , I need to send an ACK message which looks like this:

<message id="">
  <gcm xmlns="google:mobile:data">
  {
      "to":"REGID",
      "message_id":"m-123"
      "message_type":"ack"
  }
  </gcm>
</message>

My server receives the message I send from my Android application and I send this Ack message:

<message to="devices@gcm.googleapis.com" id="R88Ub-10">
    <gcm xmlns="google:mobile:data">
    {
        "to":"dpDymtuUdEO-...-MRDQvLXMhfnEEUqEYZfs",
        "message_id":"64cc690-...-227a0b7eb61",
        "message_type":"ack"
    }
    </gcm>
</message>

(The "-...-" part is just to shorten/anonymize the code)

But if I restart my server, I receive some messages I allready got and allready send an ACK for... I tested without "to" and "id" in my tag, but nothing seems to work.

The "to" I use in my ACK message is the "from" of the message I want to ACK.

What am I doing wrong? I use Smack as XMPP library.

After being in contact with the Firebase Team, we found that setting the TTL (Time To Live) for the messages to '0' helped. The code that sends the FCM message now looks like this:

                 fcm.send(new RemoteMessage.Builder(FCMConstants.SENDER_ID + "@gcm.googleapis.com")
                  .setMessageId(msgid)
                  .setData(data)
                  .setTtl(0)
                  .build());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM