This article lets you know about App push

Push related introduction

When the user does not open the App, the server pushes the latest message data of the server to the user, which is called push. Message push is used in many scenarios in mobile development, such as product promotion activities of typical e-commerce apps, news push of information apps, and so on. In actual development, we often develop the push function according to the needs of product design. However, in the implementation process, many problems will be faced, such as: how to achieve it? Do you implement it yourself or choose a third-party push? How to choose third-party push? How to ensure the data security of message push? How to ensure the arrival rate of push? In fact, these pain points are mainly on Android phones, and the focus of this article is also on the push on Android phones.

part1: Comparison between iOS push and Android system push

The iOS push service notification is completed by its own dedicated push server APNs (Apple Push Notification service). The process is that APNs receives the pushed message sent by our own application server and pushes the message to the specified iOS device , and then notified by the iOS device to the application, and then prompted or displayed. The premise of iOS remote push is that the iOS device with our application needs to be registered with the APNs server. When we need to push a message, our application server packages the message according to the specified format, and then sends it to the APNs server together with the devicetoken of the iOS device. Our application will maintain a TCP-based long-term connection with the APNs server, and the APNs server will push new messages to the iOS device, and then display the pushed messages on the device screen. (Note: All third-party pushes must go through the Apple server APNs).

And every Android application that needs to be pushed in the background must have a separate background process in order to communicate and exchange data with their respective servers. In fact, Android also has a service similar to APNS's GCM (Google Cloud Message). If the Android application push adopts this mode, it will be the same as the iOS push. GCM-related programs should be integrated in so-called Gapps. However, due to the fact that the GCM of Android mobile phones in China is basically unavailable, and the serious fragmentation of Android devices, it leads to the above problems that have to be considered when doing Android push.

part2: The essence and principle of push

The essence of message push is: the App pushes the updated information of the server to the user, that is, the App obtains the server information, and then pushes it to the user. There are two basic ways (principles) for the App to obtain the latest news from the server: Push and Pull

  • Active acquisition method (Pull): The client actively obtains information from the server at regular intervals to see if there is updated information; if there is updated information, it is sent to the client
  • Passive acceptance mode (Push): When the server has updated information, it is actively sent to the client

Contrast: The Push method is superior to the Pull method. Because the client needs to continuously monitor the changes of the server when using the Pull method, which consumes more resources of the client (CPU resources, network traffic, system power)

part3: Several solutions for implementing message push in Android

After understanding the principle of push, let's talk about several solutions for implementing message push in Android:

Solution 1. Use GCM service (Google Cloud Messaging)

Introduction: The cloud messaging service launched by Google is the second generation of G2DM.

Advantages: The services provided by Google are native and simple, without the need to implement and deploy the server.

Disadvantages: The service is not stable enough in China and requires users to bind a Google account, which is limited by Google.

Scenario 2. Polling

Introduction: Based on the Pull method, the application actively connects to the server at regular intervals and queries whether there are new messages.

Disadvantages: high cost, you need to realize the communication with the server yourself, such as message queuing, etc.; the arrival rate is uncertain, consider the frequency of polling: too low may cause message delay; too high, more resources on the client (CPU resources , network traffic, system power) and server resources (network bandwidth)

Scenario 3.SMS (short message sending)

Introduction: By intercepting SMS messages and parsing the message content to understand the server's intent, and obtain its display content for processing.

Advantages: Full real-time operation is possible.

Disadvantages: relatively high cost. Because at present, it is difficult to find a free short message sending gateway to realize this solution, only by paying the corresponding short message fee to the operator.

Solution 4. Use the MQTT protocol (for more information, see:  http://mqtt.org/ )

Introduction: A lightweight, agent-based "publish/subscribe" mode message transfer protocol.

Advantages: The protocol is concise, compact, highly scalable, traffic-saving, and power-saving. It has been applied to the enterprise field (reference:  http://mqtt.org/software ), and there is a C++ version of the server component rsmb.

Disadvantages: immature, complex implementation, not open source server component rsmb, high cost of deploying hardware.

Solution 5, using the XMPP protocol (Openfire + Spark + Smack)

Introduction: Communication protocol based on XML protocol, formerly known as Jabber, has been standardized by IETF International Standardization Organization.

Advantages: The protocol is mature, powerful, and highly scalable. It is currently mainly used in many chat systems, and there is an open source Java version of the development example androidpn.

Disadvantages: The protocol is complex, redundant (based on XML), traffic and electricity are consumed, and the cost of deploying hardware is high.

Scenario 6. Use a third-party platform

Introduction: Use a third-party message push platform. Today's mainstream push platforms are divided into ------

Mobile phone manufacturers: such as Xiaomi Push, Huawei Push...

Third-party platforms: Youmeng Push, Jiguang Push, Getui...

The platform push of BAT manufacturers: Alibaba Cloud Mobile Push, Tencent Cloud Mobile Push, Baidu Cloud Push.

It will be described in detail below.

part4: Detailed introduction of the third-party message push platform

1. Classification of mainstream third-party push platforms

Mobile phone manufacturers: Xiaomi Push, Huawei Push...

Third-party platforms: Youmeng Push, Jiguang Push, Getui...

The platform push of BAT manufacturers: Alibaba Cloud Mobile Push, Tencent Mobile Push, Baidu Cloud Push

2. Compare the characteristics of other push methods

  • Can effectively reduce costs

Most of the above-mentioned pushes are free, if you implement it yourself, it will consume too many resources (development costs and background management, statistics costs)

  • High message arrival rate

If multiple apps in a mobile phone use the same push service, these apps will share a message channel. Even if your app push service is killed, as long as the user opens other apps that integrate the push service, Home push can reach users.

  • low security

Using other people's servers, there is still a risk of data leakage. (However, some push services support private servers and require ¥)

  • service will be killed

Due to the mechanism of the Android system, the background push Service will be killed by various active or passive behaviors, and once the service is killed, it means that the push message cannot be received. (Some push services support integrated vendor channels, so integrated vendor channels can improve the (offline) push arrival rate, but it also requires ¥)

part5: How to choose third-party platform push service?

Knowing the characteristics of third-party push, how should we choose? It is necessary to clarify three principles that need attention.

1. Pushed by mobile phone manufacturers

Please remember an unspoken rule: the operating system will not kill the push service of its own brand.

The mobile phone manufacturer's push service is a system-level service on its own mobile phone, which means that the system will not kill its own push service. For example, the Android native system will not kill the C2DM message push service, and the MIUI system will not kill Xiaomi's push service.

3f795f828890406a8df0693272b59da8.png

 

(Screenshot of Xiaomi Push official website - integrated application)

From the Xiaomi Push official website, we can see that most of the mainstream apps in the market have integrated Xiaomi Push.

2. Third-party platforms

Please remember a rule: the push system will share a push channel.

This means that assuming you have connected to Youmeng Push, and it happens that Toutiao is also connected to Youmeng. One day your app is killed, but at this time the user starts Toutiao, then the push system will send your push messages to the mobile phone through the shared push channel (the push arrival rate is improved), and then it is possible Wake up your process too (was "kept alive"). Therefore, regarding how to choose a third-party platform for push, the scale effect of the push platform is very important.

So how do you know their size and market share? Mainly look at two points:

  • Ask your friends inside.

  • See which big apps are among the cooperative customers of the push platform - refer to the cooperation cases on the corresponding official website.06cd9864c2304389af0f60e74b0537bb.png

 

(Screenshot of Getui official website - integrated application)

3. Push from major BAT manufacturers

In a word: The push of big BAT manufacturers does not actually have any advantages.

Some people may think that by using Tencent Mobile Push, they can take advantage of WeChat and ensure that your app will never be killed. That is an illusion. As for Aliyun’s mobile push, I can’t see how many mainstream applications in the market use it, but I can see that Taobao uses other third-party push (such as Youmeng Push, Xiaomi Push) on other platforms.

In addition to the above three principles, we also need to consider the following factors when choosing a push platform:

User group attribute (equipment): What kind of user group and what kind of equipment are mostly used. Then you can consider mobile phone manufacturers.

Reach rate: For example, whether to integrate Xiaomi and Huawei push, or whether to integrate manufacturer channels when choosing a third-party platform, the scale of the third-party platform...

Realization cost: labor cost, time cost, capital cost...

Therefore, we need to choose a message push platform according to our own situation.

part6: Selection of push message category

1. Types of push messages

Generally, third-party push platforms support two types of push messages: notification bar messages and transparent transmission messages.

Notification bar message: After this type of message is delivered to the user's device, it will be directly displayed to the user in the form of the system notification bar and will not be passed on to the App.

Transparent message transmission: After this type of message is delivered to the user's device, it will continue to be transmitted to the App, and the message will be transmitted to the inside of the App by calling back a BroadcastReceiver of the App. It is then up to the App to decide how to process and display this message.

Therefore, the transparent transmission message may not necessarily be pushed in the form of the system notification bar, which is customized by the programmer.

2. Differences and characteristics of message categories

The difference between the two is that the transparent transmission message has one more step than the notification bar message in the whole message transmission process—passing to the App

Advantages of notification bar messages: high delivery rate

Because the transparent transmission message is one step more than the notification bar message in the whole message transmission process-passing to the app, so the transparent transmission message increases the probability of being restricted by the system, and the probability of being killed by the system is higher, so the notification bar Messages should provide better deliverability than passthrough messages.

Advantages of transparent message transmission:

  • High degree of message operation & high degree of customization.
  • Provides more flexible manipulation capabilities on message data.
  • If the app only passes the notification bar message, it cannot access the message data itself.
  • The style of notification reminder can be customized (including prompt style, prompt form such as sound, etc.)

Summarize

The above not only gives a comprehensive and detailed introduction to push and push implementation schemes and third-party push, but also explains the factors that need to be considered and matters to be paid attention to when choosing a third-party push. Although there is no separate introduction to security and how to improve the message arrival rate, some mentions are interspersed in other content. I hope you can gain something after reading it.

 

Guess you like

Origin blog.csdn.net/qq_36162336/article/details/126172983