Android push solution and android push Solution
MobilePush ServiceIs to establish a link between the mobile phone and the server. When a message needs to be sent to the mobile phone, it can be sent through this link.
Android push is implemented in the following ways:
Solution 1. Use the C2DM Service (Google Cloud Messaging)
Introduction: The cloud message service launched by Google, that is, the second generation G2DM.
Advantages: The services provided by Google are native and simple. You do not need to implement or deploy the server.
Disadvantages: The Android version is limited (must be later than Version 2.2). This service is not stable enough in China and users need to bind Google accounts, because Google is limited.
Solution 2: Use XMPP protocol (Openfire + Spark + Smack)
Introduction: XML-based communication protocol, formerly Jabber, has been standardized by the IETF International Standardization Organization.
Advantages: The Protocol is mature, powerful, and highly scalable. It is mainly used in many chat systems and has an open-source Java version Development Instance androidpn.
Disadvantages: The Protocol is complex, redundant (based on XML), paybytraffic, power consumption, and high hardware deployment costs.
Solution 3: Use the MQTT Protocol
Introduction: Lightweight, proxy-based "Publish/subscribe" message transmission protocol.
Advantages: The Protocol is concise, compact, highly scalable, traffic-saving, and power-saving. It has been applied to the enterprise field, and the C ++ version of the server component rsmb already exists.
Disadvantages: Not mature enough, complicated implementation, server component rsmb is not open-source, and the hardware deployment cost is high.
Solution 4: Use third-party push services
Introduction: Use third-party push services through embedded sdks.
Google cloud PUSH Service: In special cases in China, most domestic mobile phones have cut down the Google service, so this implementation method is not realistic.
Baidu cloud PUSH Service: The implementation of this push solution is relatively simple. You can directly integrate the relevant sdk to implement push, and the server-side sdks include PHP, Java, and Python versions, you can also directly push related messages through URLs.
Aurora push: This document is comprehensive. It is called a three-minute quick Demo, which is much easier to integrate.
Advantages: Stable and mature, saving development and exploration time, low development costs, and complete push management interface and statistical procedures.
Disadvantages: Program embedding concerns.
The following section briefly introduces how to use the third solution, hoping to help developers avoid detours during development ~
1. First download the rsmb package, decompress it, and find the corresponding server folder. The editor displays linux_ia32, which supports multiple servers.
2. Upload the Directory and files to the server, enter the command line, and enter the directory./broker to start the PUSH Service.
3. Prepare the push page to download the PHP push code (Click here to download), Decompress it into the etc directory and change the IP address in config. php to your server IP address.
4. Open the corresponding url to see the following page
The Server status is displayed as Online, indicating that the Server is started properly.
5. Prepare the android client (Click me)
Download --> decompress --> Import eclipse --> modify MQTT_HOST in PushService to your server IP Address --> RUN
Start the PUSH Service, and input the string of characters into the input box above on the webpage above, and enter the content to be pushed below.
The following content describes how to solve the problem. For more information, see >>>
Recommended articles:
How is push implemented in android and ios systems? Why is there no background push in ios?
Comparison of Android push Solutions
Generally, there are two methods to obtain information updated from time to time on the server. The first method is that the client uses the Pull method to obtain information on the server from time to time, check whether any updated information appears. The second approach is to use the Push method on the server. when new information is available on the server side, the latest information is pushed to the client. Although both the Pull and Push methods can obtain the server-side update information, the Push method is obviously better. Because the Pull method charges more client network traffic, it also consumes power at the same time. When developing Android and iPhone applications, we often need to push various notification messages from the server to the mobile client in real time, the iPhone already has a relatively simple and perfect push notification solution, but it is relatively troublesome to implement it on the Android platform. On the Android mobile platform, Google provides the C2DM (Cloudto Device Messaging) service. Android Cloud to Device Messaging (C2DM) is a service that helps developers send data to Android applications from servers. The Service provides a simple and lightweight mechanism that allows the server to notify mobile applications to communicate directly with the server, so that the server can obtain application updates and user data. The C2DM service processes transactions such as Message Queuing and distributes these messages to applications running on the target device. C2DM operation process diagram: however, this service has some problems: 1) C2DM is built into the Android 2.2 System and cannot be compatible with the old 1.6 to 2.1 systems; 2) c2DM depends on the C2DM Server officially provided by Google. Due to the domestic network environment, this service is often unavailable. If you want to use it well, the App Server must also be abroad, this may not be implemented by every developer. If C2DM cannot meet your requirements, you need to implement the communication protocol between the Android mobile client and the App Server on your own to ensure that when the App Server sends messages to a specified Android device, android devices can receive messages in a timely manner. The following describes several common solutions: 1) Round Robin (Pull): the application should be connected to the server periodically and check whether new messages arrive, you must implement communication with the server, such as Message Queuing. In addition, you also need to consider the polling frequency. If it is too slow, it may lead to delay of some messages. If it is too fast, it will consume a lot of network bandwidth and battery. 2) SMS (Push): On the Android platform, you can intercept SMS messages and parse the message content to understand the server's intention. This is a good idea. Some programs on the market adopt this solution. The advantage of this solution is that it can achieve full real-time operations. However, the problem is that the cost of this solution is relatively high, and it is difficult for you to find a free short message sending gateway to deploy this solution. 3) persistent connection (Push): this solution can solve the performance problem caused by polling, but it will still consume the cell phone's battery. The push service of Apple works well because each mobile phone only maintains a connection with the server. In fact, C2DM works like this. However, this solution also has shortcomings, that is, it is difficult for us to implement a reliable service on the mobile phone. The Android operating system allows you to Kill system services with low memory, so your notification service may be killed by the operating system. There are deficiencies in all three schemes, but they can be compensated through good design so that the scheme can work effectively. After all, you must know that GMail, GTalk, and GoogleVoice can all be updated in real time. MQTT is a lightweight message publishing/subscription protocol. It is an ideal solution for message pushing servers based on mobile clients. Wmqtt. jar is the implementation of the MQTT protocol provided by IBM. You can download it from the following website.
Push solution for Android platform
I am using smart game push, not bad