Protocol used for sending push notification in Android

后端 未结 4 1800
独厮守ぢ
独厮守ぢ 2021-02-04 09:39

I want to know which protocol is used to send push notification to android devices and which to send push notification requests to GCM.

Whether it is HTTP, HTTPS or some

相关标签:
4条回答
  • 2021-02-04 10:25

    It uses both HTTP and XMPP

    When the message is processed successfully, the HTTP response has a 200 status and the body contains more information about the status of the message (including possible errors). When the request is rejected, the HTTP response contains a non-200 status code (such as 400, 401, or 503).

    iOS however, requires a dedicated TCP connection on a proprietary port, and GAE environment doesn't allow any external protocol except HTTP over port 80.

    enter image description here

    The message size limit is 1024 bytes. Google limits the number of messages a sender sends in aggregate, and the number of messages a sender sends to a specific device

    enter image description here

    This is how these components interact:

    Google-provided GCM Connection Servers take messages from a 3rd-party application server and send these messages to a GCM-enabled Android application (the "client app") running on a device. Currently Google provides connection servers for HTTP and XMPP. The 3rd-Party Application Server is a component that you implement to work with your chosen GCM connection server(s). App servers send messages to a GCM connection server; the connection server enqueues and stores the message, and then sends it to the device when the device is online. For more information, see Implementing GCM Server. The Client App is a GCM-enabled Android application running on a device. To receive GCM messages, this app must register with GCM and get a registration ID. If you are using the XMPP (CCS) connection server, the client app can send "upstream" messages back to the connection server. For more information on how to implement the client app, see Implementing GCM Client.

    Check out this for more details -->

    Google Cloud Messaging for Android (GCM)

    Android Cloud to Device Messaging Framework

    Cloud Messaging

    Cloud to Device Messaging

    0 讨论(0)
  • 2021-02-04 10:26

    There are two protocols http and xmpp which you can use to send message to GCM server.

    Now its up to you what you want to use. If you want to broadcast message then u should go with http.

    you can broadcast 1000 message in a single http request. And only one message through xmpp in a request...

    Http can be used only for down streaming(3rd party app server -gcm-mob device)

    But gcm won't support up streaming using http. for that you should use xmpp.Xmpp can be used for both up streamlining and down streaming.

    Implementaction of push notification can be very easy if you are going with http and that much more hard if you are going with xmpp.but Google has provided detail tutorial how to implement xmpp. So please have a look On Google developer site.

    0 讨论(0)
  • 2021-02-04 10:36

    Looking at @user3523641's answer and further conversation, I'll try to explain further:

    The way of delivering messages is based on the protocol that you've chosen, either HTTP or XMPP (i.e., it's the same). The magic and basic way of working is leaving a socket opened between the GCM server and the user's device.

    This way, when an user should receive a message, this opened socket will be used and send the message through itself. This also helps the GCM server knowing which devices are connected or not. So this way, if your third party server says a message should be sent to a user and the GCM server knows the user is not connected, it won't send it at that time, but will try once the connection is again established, so it won't waste connection attempts in vain. The default timeout is 4 weeks, however, it can be changed.

    As per the official GCM documentation:

    If the device is not connected to GCM, the message will be stored until a connection is established (again respecting the collapse key rules). When a connection is established, GCM will deliver all pending messages to the device, regardless of the delay_while_idle flag. If the device never gets connected again (for instance, if it was factory reset), the message will eventually time out and be discarded from GCM storage. The default timeout is 4 weeks, unless the time_to_live flag is set.

    Finally, when GCM attempts to deliver a message to the device and the application was uninstalled, GCM will discard that message right away and invalidate the registration ID. Future attempts to send a message to that device will get a NotRegistered error. See How Unregistration Works for more information.

    You can find more info here.

    0 讨论(0)
  • 2021-02-04 10:39

    The protocols of the communication between the 3rd party server and GCM server (HTTP or XMPP) were already mentioned in the other answers.

    The protocol of the communication between the device and GCM server is not discussed in the GCM documentation, since you never have to access it directly as an Android application developer, and therefore you don't need to know about it.

    However, here's a quote from a Google developer from the team that created GCM, which says a few things about the connection. From what he says, you can only know that it's a long-lived TCP connection.

    GCM maintains a long-lived connection - and reconnects if it knows the connection was broken. A router/AP/NAT is supposed to send a FIN or RST to terminate the TCP connection - so GCM and servers will know the connection is dead.

    However a number of routers and mobile operators don't do this, and then GCM needs to rely on the heartbeat, ~15 min on Wifi, more on mobile.

    (The quote is taken from an answer by that person)

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