Google Cloud Messaging - CCS (XMPP) vs HTTP server

前端 未结 5 1325
执念已碎
执念已碎 2020-12-30 03:53

I\'ve read the documentation https://developer.android.com/google/gcm/index.html

and the only difference I can see is that a CCS (XMPP) based server allows bi-direct

相关标签:
5条回答
  • 2020-12-30 04:17

    XMPP messaging differs from HTTP messaging in the following ways:

    Upstream/Downstream messages

    • HTTP: Downstream only, cloud-to-device.
    • XMPP: Upstream and downstream (device-to-cloud, cloud-to-device).

    Messaging (synchronous or asynchronous)

    • HTTP: Synchronous. App servers send messages as HTTP POST requests and wait for a response. This mechanism is synchronous and blocks the sender from sending another message until the response is received.
    • XMPP: Asynchronous. App servers send/receive messages to/from all their devices at full line speed over persistent XMPP connections. The XMPP connection server sends acknowledgment or failure notifications (in the form of special ACK and NACK JSON-encoded XMPP messages) asynchronously.

    JSON

    • HTTP: JSON messages sent as HTTP POST.
    • XMPP: JSON messages encapsulated in XMPP messages.

    Plain Text

    • HTTP: Plain Text messages sent as HTTP POST.
    • XMPP: Not supported.

    Multicast downstream send to multiple registration tokens.

    • HTTP: Supported in JSON message format.
    • XMPP: Not supported.
    0 讨论(0)
  • 2020-12-30 04:20

    From Google docs :

    You can continue to use the HTTP request mechanism to send messages to GCM servers, side-by-side with CCS which uses XMPP. Some of the benefits of CCS include:

    The asynchronous nature of XMPP allows you to send more messages with fewer resources.

    Communication is bidirectional—not only can your server send messages to the device, but the device can send messages back to your server.

    The device can send messages back using the same connection used for receiving, thereby improving battery life.

    0 讨论(0)
  • 2020-12-30 04:27

    CCS (XMPP) is asynchronous, which means it should be faster than HTTP. It also uses the existing GCM connection on the device to send messages from your app to your server (which saves battery, since you don't have to open your own connection to your server).

    On the other hand, HTTP is much simpler to code, so unless you need the bi-directional functionality or you need to send messages in a very high speed, I'd stick with HTTP.

    0 讨论(0)
  • 2020-12-30 04:33

    You can broadcast a message to 1000 devices at a time with a single http call to gcm. For broadcasting http is better than CCS.

    0 讨论(0)
  • 2020-12-30 04:33

    unfortunately google cloud platform will disable the XMPP API after a year https://cloud.google.com/appengine/docs/deprecations/xmpp

    I'd choose XMPP to save devices battery cause its one of the big concern nowadays!

    0 讨论(0)
提交回复
热议问题