Android Fusion Push MixPush SDK integrates multiple push platforms, sharing system-level push, killing APP can also receive push

Message push is an important part of App operation. In order to optimize the success rate of message push and reduce power and traffic consumption, system-level push service is particularly important. Millet and Meizu have launched their own push platform, sharing system-level push services on MIUI and Flyme, so that APP can receive normal push messages when it is killed. In the future, more and more mobile phone manufacturers will launch their own push platform, and MixPush will come into being, which will reduce the development cost of developers integrating multiple push and improve the arrival rate of push.

Project Open Source Github

Recommendation Push Platform

Millet push

Supports all Android platforms, featuring sharing system-level push on MIUI systems, and receiving notification bar push when APP is killed.

Meizu push

Flyme system can not be used on non-Flyme system only. It is characterized by sharing system-level push in Flyme system and receiving notification bar push when APP is killed.

Push and push

Android platform, the largest third-party push platform, stable push messages.

Schematic diagram

Principle analysis

MixPush is just a framework to reduce the integration of multiple push services. It does not own push functions. All push functions are implemented by various push platforms. As can be seen from the schematic diagram, the client APP will register different push platforms according to different mobile phones, and can not register two push services at the same time to avoid repeated receipt of push. The server does not need to consider which platform the user's mobile phone needs to push messages belongs to, and will launch push messages to all platforms, while the client will only receive push messages from a single platform according to the registered platform.

Android client configuration

Add the warehouse address and modify the build.gradle file in the root directory:

    allprojects {
        repositories {
            maven { url '' }

Choose the push platform, if there is no reference source code to implement by itself, add dependencies:

dependencies {
    compile 'com.github.joyrun.MixPush:client-core:1.0.0' //Must fill
    compile 'com.github.joyrun.MixPush:client-mipush:1.0.0' // Millet push
    compile 'com.github.joyrun.MixPush:client-getui:1.0.0' // Push
    compile 'com.github.joyrun.MixPush:client-meizu:1.0.0' // Meizu push, Meizu push only supports Flyme system, must pay attention to

Create a service class inheriting MixPushIntentService to receive events:

public class PushIntentService extends MixPushIntentService {
    public void onReceivePassThroughMessage(MixPushMessage message) {
        Log.e(TAG, "Receive through message -> " + message.getContent());

    public void onNotificationMessageClicked(MixPushMessage message) {
        Log.e(TAG, "Notice Bar Message Click -> " + message.getContent());

Configure AndroidManifest.xml to register service classes

    <application ...>
        <service android:name=".PushIntentService"/>

Initialize in the Application class. If not, create your own:

public class DemoApplication extends Application {
    public static final String MEIZU_APP_ID = "<MEIZU_APP_ID>";
    public static final String MEIZU_APP_KEY = "<MEIZU_APP_KEY>";
    public static final String MIPUSH_APP_ID = "<MIPUSH_APP_ID>";
    public static final String MIPUSH_APP_KEY = "<MIPUSH_APP_KEY>";
    public void onCreate() {
    private void initPush() {
        MixPushClient.addPushManager(new MeizuPushManager(MEIZU_APP_KEY, MEIZU_APP_ID));
        MixPushClient.addPushManager(new MiPushManager(MIPUSH_APP_ID, MIPUSH_APP_KEY));
        MixPushClient.addPushManager(new GeTuiManager());
        MixPushClient.setSelector(new MixPushClient.Selector() {
            public String select(Map<String, MixPushManager> pushAdapterMap, String brand) {
                // return GeTuiManager.NAME;
                //The bottom has already made millet push, Meizu push, individual push judgment, and can also choose push according to their own needs.
                return, brand);
        // Configure the service class that receives push messages
        // Registration push
        // Binding aliases, usually filling in the user's ID, facilitates directional push
        MixPushClient.setAlias(this, getUserId());
        // Set labels to divide users
    private String getUserId(){
        return "103";

Modify the build.gradle file of APP and configure the push APP ID and other information

android {
    defaultConfig {
        manifestPlaceholders = [
                GETUI_APP_ID : "<GETUI_APP_ID>",
                GETUI_APP_KEY : "<GETUI_APP_KEY>",
                GETUI_APP_SECRET : "<GETUI_APP_SECRET>",
                PACKAGE_NAME: "<APP The name of the package>"

Customize icons for notification boards

Millet push

At present, the message of notification class, the icon display rules of notification are as follows:

  1. If there are drawable files named mipush_notification and mipush_small_notification in app, the drawable of mipush_notification is used as the big icon of notification, and the drawable of mipush_small_notification is used as the small icon of notification.
  2. If only one drawable file exists in the app, the drawable is used as an icon for notification.
  3. If these two drawable files do not exist in app, the icon of app is used as the icon for notification. In MIUI, the notification bar icon is uniformly displayed as the icon of app, which can not be customized.
Push and push

To modify the default prompt icon at the top of the notification bar, place the corresponding size of the file named push.png picture under the resolving directories of res/drawable-ldpi/, res/drawable-mdpi/, res/drawable-hdpi/, res/drawable-xhdpi/, res/drawable-xhdpi/, etc.

ldpi:    48*48
mdpi:    64*64
hdpi:    96*96
xhdpi:   128*128
xxhdpi:  192*192
Meizu push

It's the same as millet push.

Be careful

  1. Meizu push only supports Flyme system, it must be noted.

Server Configuration Test

At present, only Java server-side code, if the server uses other languages, please refer to the design ideas to develop their own.

Copy code and jar packages to the project.

Server-side push testing
public class MixPushServerTest {
    public static final String APP_PACKAGE_NAME = "<APP The name of the package>";
    public static final String MIPUSH_APP_SECRET_KEY = "<MIPUSH_APP_SECRET_KEY>";

    public static final Long MEIZU_APP_ID = <MEIZU_APP_ID>;
    public static final String MEIZU_APP_SECRET_KEY = "<MEIZU_APP_SECRET_KEY>";

    public static final String GETUI_APP_ID = "<GETUI_APP_ID>";
    public static final String GETUI_APP_KEY = "<GETUI_APP_KEY>";
    public static final String GETUI_MASTER_SECRET = "<GETUI_MASTER_SECRET>";
    public static final String GETUI_URL = "";
    static {
        MixPushServer.addPushServerManager(new MiPushServerManager(APP_PACKAGE_NAME, MIPUSH_APP_SECRET_KEY));
        MixPushServer.addPushServerManager(new MeizuPushServerManager(MEIZU_APP_ID, MEIZU_APP_SECRET_KEY));
        MixPushServer.addPushServerManager(new GeTuiPushServerManager(GETUI_APP_ID, GETUI_APP_KEY, GETUI_MASTER_SECRET, GETUI_URL));
    String title = "title";
    String description = "description";
    String json = "{\"name\":\"Wiki\",\"age\":24}";
    public void sendNotifyToAll() throws Exception {
        MixPushServer.sendNotifyToAll(title, description, json);
    public void sendMessageToAll() throws Exception {
    public void sendMessageToAlias() throws Exception {
        MixPushServer.sendMessageToAlias("100", json);
    public void sendMessageToTags() throws Exception {
        MixPushServer.sendMessageToTags("Guangdong", json);
    public void sendNotifyToAlias() throws Exception {
        MixPushServer.sendNotifyToAlias("100", title, description, json);
    public void sendNotifyToTags() throws Exception {
        MixPushServer.sendNotifyToTags("Guangdong", title, description, json);

If you don't use the above three pushes, you can also implement them according to the interface itself.

Tags: Android JSON Flyme github

Posted on Thu, 06 Jun 2019 15:26:09 -0400 by PHPcadet