Android Push service: Baidu Cloud push

Source: Internet
Author: User
Tags comparison message queue

Introduction of Push Service

Message push, as the name suggests, is initiated by a party, and the other party and the initiator in a certain way to establish a connection and receive messages. In Android development, the initiator here we call it the push server, and the receiver is called the client. In comparison with polling to get new messages or notifications, push is better than polling for both the client's resource consumption and device power consumption, so the vast majority of apps that need to be pushed in a timely manner are using push for message notification.

The Android ecosystem originally provided a gcm similar to the Apple iOS push service APNs (Google Cloud Messaging for Android), formerly known as C2DM, but for some reason the service was not very good at home, In order to make up for this deficiency, and I want to use Android push service, so the major platforms in China has launched a GCM alternative, today to introduce is one of them, by the cloud of Baidu to push. In addition, the domestic news push service also has aurora push and a push and so on, their clients include Sina Weibo, Taobao and other domestic first-line large companies.

The push implementation technology is simply to use the socket to maintain a TCP long connection between the client and the server, which can greatly reduce the device power consumption and data access traffic caused by the polling method. At present, the Baidu Cloud push provides the push service to support a single message body size is 4k, if more than 4k, it is recommended to carry a service request URL in the message two requests. At present, Baidu Cloud push for the Android side to provide notification push, text message push and rich media push.

Second, the use of the scene

1. Unicast message push

Push server pushes a message to a specified device (Device) or user (users), one user corresponds to a userid, and one person may have multiple Device, and when we want to push messages to the same userid, All of his UserID-bound device received the message. The solution that Baidu Cloud pushes out is to register with push server through client, and obtain the Channelid and userid,channelid that push server returns in the client side listening port to specify a terminal, in the push During server registration, device can send Imie code or UUID as a unique indicator, and then return to the client-generated channelid and userid after the push server is registered. After the two IDs are secured by the developer, the push server maintains a list of registered devices that maintain the UserID and Channelid as well as the relationship to the device, and when it is necessary to push messages to the specified device or user, push The server first iterates through the list of devices, using these two IDs to make a unique judgment and find the device that needs to be pushed, and then you can push the message.

Example: When user A issues a problem, record the problem ID and its corresponding a userid (or channelid), and User B issues the answer, push the answer through the server-side API to the UserID (or channelid) that corresponds to the problem ID.

2. Packet message push

Baidu Cloud push through the client set tag (tag) way to the user group, tag can be generated by the client maintenance can also be collected by the server, push server for different Tag for push filter, and eventually push the message to the designated client. Whether the client is actively set up by the tag or by the server based on user habits collected by the push server for unified management, in the tag based packet message push implementation, push Server first according to the specified tag from all under the tag through the corresponding registered device, so that the corresponding UserID and channelid can be obtained with the device, which can then be sent to the designated tag packet message push. Compared to unicast message push, packet message push is bound to be longer in the push cycle, and in the maintenance of the list of pending messages also need to do some processing, which messages are pushed successfully, which is failed, which requires the recipient of the message pushed by the client after receiving the message to push server a message receipt, This guarantees the accuracy of message delivery, and if a message push fails, the push message in the grouped list will continue to push until the message is pushed successfully. In addition, in the real-time of message push, packet message push VS unicast message push will have a message receiving delay according to the packet message queue, like now micro-credit to the public account of the push, is a packet message push instance, in the message received the timeliness of the comparison of unicast push has a certain delay.

In addition, there is a class of message push use scenario, that is, broadcast messages, which can be understood as a special column of packet messages, that is, to all the tag corresponding to the Client push message. Broadcast messages are a message push to the whole set, which is more expensive than a single or a few tag packets for Message Queuing maintenance and message-push timeliness.

Example: to provide preferences for the application of the page, users tick different categories, triggering the corresponding tag settings, this way is the active maintenance of the client tag. Or the user read a category of books, triggering the corresponding tag settings, in the service side, to the specified category of books set tag, follow-up will be collected in accordance with the server tag to the application push the tag under the new book information, this way is by the service side to maintain the tag group.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.